Android -- tools
Android has a dedicated XML namespace that enables the tool to record information in XML files, in addition, information is stripped out of the package to a degree that will not negatively affect the running period and download size. The URI of this namespace is http://schemas.android.com/tools, and is usually bound to tools: 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" ></FrameLayout>
This tool label is mainly used by the adt plug-in. Many of its attributes can be easily developed, but will not affect our final apk package. For example, when you write an interface, you usually write text values to Textview and delete it after development. This operation is very troublesome, but now you can. Tools: ignore this attribute can be set on any XML element. It is a list of comma-separated lint question IDs, indicates the ID of the lint issue that should be recursively ignored on this element or any of its child elements. <String name = "show_all_apps" tools: ignore = "MissingTranslation"> All </string> tools: context
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" tools:context=".MainActivity" />
Tools: context = ". MainActivity" is not packaged into the APK. Only the Layout Editor of ADT sets the corresponding rendering context in your current Layout file, indicating that the rendering context of your current Layout is the activity corresponding to the activity name, if Theme is set for this activity in the manifest file, the Layout Editor of the ADT will render your current Layout based on the Theme. It is only used to show you what you see is what you get. (One more thing: The "tools" namespace is special. the android packaging tool knows to ignore it, so none of those attributes will be packaged into the APK. we're re using it for extra metadata in the layout. it's also where for example the attributes to suppress lint warnings are stored -- as tools: ignore .) tools: targetApi this attribute is the same as @ TargetApi annotation in the 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" ......... >tools:text<TextView android:text="text" tools:text="tools text" ......... >
Tools: text is actually used for ADT. It is used to preview the value of this attribute on the design page, but this value is not visible during actual running. Tools: listitem/listheader/listfooter provides ADT for you to preview the listview layout. <ListeView tools: listview = "@ android: layout/simple_list_item_1" ......> tools: locale this attribute can be set on the root element of the resource file, and should correspond to a language or a region. This will let the tool know the language (region) in which the file string is assumed. For example, values/strings. xml can have this root element: <resources xmlns: tools = "http://schemas.android.com/tools" tools: locale = "es"> tools: layout this property is typically set in a label, used to record the layout you want to see during design (during runtime, it is determined by the operation of the fragment class listed in this label ).
<fragment android:name=".MyFragment" tools:layout="@android:layout/list_content" />tools:showIn
This attribute is set on the root element of a layout with other la S. This allows you to point to one of the la s that contain the layout. during design, the included layout is rendered with the surrounding external layout. This allows you to view and edit the layout in the context.
<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" />tools:menu
This attribute is set on the root element of the layout to configure the menu displayed in the Action Bar. Android Studio uses the onCreateOptionsMenu () method in the activity linked to the layout file (via tools: context) to find out which menus are used in the ActionBar. It allows you to override the search and display declaration menus for display. Its values are IDs separated by commas (,) (no @ id/or any such prefix ). You can also use the name of the menu xml file without the. xml extension. X
<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" />tools:actionBarNavMode
This attribute is set on the root element of the layout to configure the navigation mode used by the Action Bar. Possible values include "standard", "list", and "tabs ".
<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" />