Android official technical document translation--tool properties

Source: Internet
Author: User

This article is translated from Androd official technical document "Tools Attributes": http://tools.android.com/tech-docs/tools-attributes

This article address: http://blog.csdn.net/maosidiaoxian/article/details/41510581. Reprint please indicate the source. Please correct me if there is any inappropriateness in the translation.


Tool PropertiesAndroid has a dedicated XML namespace that allows the tool to record information in an XML file and to strip the information to the extent that it does not negatively affect the runtime and download size of the wrapper.The URI for this namespace is http://schemas.android.com/tools, and it is usually bound to tools:in the prefix:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"     android:layout_width="match_parent"     android:layout_height="match_parent" >     ....This document records the tool properties that we are currently using. ( Note: These properties may change over time in the future. )
tools: Ignore This property can be set on any XML element, which is a comma-delimited list of lint problem IDs that represents the ID of the lint problem that should be ignored recursively on this element or on any of its child elements. <string name="show_all_apps" tools:ignore="MissingTranslation">All</string>use: Lint
tools: targetapi This property is like a @TargetApi batch annotation in a Java class: It allows you to specify an API level, which can be an integer or code name, indicating that this element needs to run above this level.     <GridLayout  tools:targetApi="ICE_CREAM_SANDWICH" > use: Lint
Tools localeThis property can be set on the root element of a resource file and should correspond to a language or a region. This allows the tool to know what language (region) The string of the file is assumed to be. For example, values/strings.xml you can have this root element: <resources xmlns:tools="http://schemas.android.com/tools"  tools:locale="es" >
Now we know that the default value of the string in the folder is in Spanish, not English.use: Lint, Studio (to disable spell checking in non-english resource files)
Tools ContextThis property is typically set in the root element of a layout XML file, documenting which activity the layout is associated with (since it is obvious that a layout can be used by multiple layouts at design time) (for example, it will be used in the layout editor to infer the default theme because the theme is defined in manifest , and is associated with activity rather than layout. You can use the dot prefix as in manifests to specify the activity class without having to use the full package name as a prefix. <android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android"  xmlns:tools="http://schemas.android.com/tools"
     tools:context=".MainActivity"  ... >use: Layout editors in Studio & Eclipse, Lint
tools: layout This property is usually set in a <fragment> tag, which is used to record the layout you want to see at design time (at run time, it will be determined by the operation of the fragment class listed in this tab). <fragment  android:name="com.example.master.ItemListFragment"  tools:layout="@android:layout/list_content"  />use: Layout editor for Studio and Eclipse
tools: listitem / listheader / listfooter These properties can be used to specify the list items used by the layout at design time <ListView> (or other adapterview subclasses, such as <GridView>,<ExpandableListView>, etc.). As well as the list header and bottom of the list. The tool will populate the fake data to show a list of some similar content.     <ListView         android:id="@android:id/list"         android:layout_width="match_parent"         android:layout_height="match_parent"          tools:listitem="@android:layout/simple_list_item_2"  />use: Layout editor for Studio and Eclipse
tools: showin This property is set on the root element of a layout that is <include> by another layout. This allows you to point to one of the layouts that contains this layout, which is rendered at design time with the surrounding external layout. This will allow you to "view and edit this layout in context." Requires Studio 0.5.8 or later. For more information, see the release statement. <TextView xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:text="@string/hello_world"     android:layout_width="wrap_content"     android:layout_height="wrap_content"      tools:showIn="@layout/activity_main"  />Use: Layout editor for Studio
Tools: Menu This property is set on the root element of the layout and is used to configure the menu that is displayed in the Action bar. Android Studio tries to find out which menus are used in ActionBar by looking at the Oncreateoptionsmenu () method in the activity (via Tools:context) that the layout file links to. It allows you to override which search and display the declared menu for display. Its value is a comma-separated list of IDs (no @id/or any such prefixes). You can also use the name of a menu XML file that does not have an. xml extension. Requires Studio 0.8.0 or later. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:orientation="vertical"     android:layout_width="match_parent"     android:layout_height="match_parent"      tools:menu="menu1,menu2"  />Use: Layout editor for Studio
tools: actionbarnavmode This property is set on the root element of the layout and is used to configure the navigation mode used by the Action Bar. Possible values include: "Standard", "List" and "tabs". Requires Studio 0.8.0 or later. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:orientation="vertical"     android:layout_width="match_parent"     android:layout_height="match_parent"      tools:actionBarNavMode="tabs"  />Use: Layout editor for Studio
Additional properties: Design-Time Propertiesin a layout, any other property can be a built-in Android property alias. For example, this allows you to set design-time-only alternative text for use in tools rather than runtimes. For more information, seeDesign-Time Layout properties.

Android official technical document translation--tool properties

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.