Using the Tools namespace

In Android Studio, we then create a layout xml file, usually in the auto-generated code, the tools will have a namespace:

xmlns:tools="http://schemas.android.com/tools"

Before I did not know is doing with, never used, then either manually delete or format the code automatically when it is deleted. Until today, only to look at the document found this stuff actually has great use! General when we draw the page, use textview sometimes need to preview look of the font size and position, I will write a text attribute very casual = "123456" and so placeholder, and when we complete the project, are generally not manually deleting text (too much). So sometimes there will be on the line when the network load text did not update 123456 circumstances arise, the experience is not very good. The use of tools can solve this problem. Attribute value as tools namespace only valid preview. In addition, when the preview, if there are tools at the same time: xxx and android: xxx, the priority display tools: preview of xxx.
Figure:

Here Insert Picture Description

No longer worried about being on the show I readily wrote out the placeholder text online.
Write a recycleView or listview, want to see under the effect of the preview is blank, just a few item, this time using the tools: listitem directly to your item layout loaded in. Preview you can see the effect of the display after running it. And the data of each entry is not the same. Very cool.
In addition, listView can also use

tools:listfooter="@layout/layout_footer"
tools:listheader="@layout/layout_header"

Preview add the head and bottom view.
Figure:

Here Insert Picture Description

Tools There are many other attributes, such as:

tools:menu
tools:openDrawer

And so on, very easy to use, you can explore a lot in the course of use.

Guess you like

Origin blog.csdn.net/u014619545/article/details/93464550