Android:如何使用包含布局的工具 [英] Android: How to use tools with include layout
问题描述
我如何使用工具:
xmlns:tools="http://schemas.android.com/tools"
使用<include>
吗?
我有一个布局A
,使用工具可以用测试数据填充所有文本字段.我有布局B
,该布局使用include
将布局A复制到其中.但是我什么时候看不到A
的测试数据.
I have a layout A
that I use tools to populate all the text fields with test data. And I have layout B
that use include
to copy layout A in to it. How ever when I do that I do not see the test data of A
.
如何查看B
中包含的A
的测试数据?
How can I see the test data of A
included in B
?
*两个布局都具有xmlns:tools="http://schemas.android.com/tools
,我什至将其推送到了布局标签.
*Both layouts have xmlns:tools="http://schemas.android.com/tools
, I even pushed it to layout tag.
推荐答案
选中此链接, Android工具属性.它应该使您了解如何使用工具属性.
具体看一下tools:showIn
属性.它基本上允许您在layout_B中渲染layout_A,其中layout_B在xml中的某处具有<include layout="@layout/layout_A"/>
.
Check this link, Android tools attributes. It should give you an idea as to how to use the tools attributes.
Specifically look at the tools:showIn
attribute. It basically allows you to render layout_A in layout_B, in which layout_B has <include layout="@layout/layout_A"/>
somewhere in the xml.
这是一个例子:
布局_A
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
tools:showIn="@layout/layout_B"
>
<!-- Your layout code goes here -->
</RelativeLayout>
layout_B
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
>
<include layout="@layout/layout_A"/>
<!-- Your layout code goes here -->
</RelativeLayout>
这篇关于Android:如何使用包含布局的工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!