Ily*_*man 11 xml android android-layout android-tools-namespace
我如何使用工具:
xmlns:tools="http://schemas.android.com/tools"
用<include>?
我有一个布局A,我使用工具用测试数据填充所有文本字段.我有布局B使用include到布局中的复制它.但是,当我这样做时,我没有看到测试数据A.
如何查看A包含的测试数据B?
*两种布局都有xmlns:tools="http://schemas.android.com/tools,我甚至把它推到了布局标签上.
Ala*_*res 20
检查此链接,Android工具属性.它应该让您了解如何使用工具属性.具体看一下tools:showIn属性.它基本上允许你在layout_B中渲染layout_A,其中layout_B <include layout="@layout/layout_A"/>在xml中的某处.
这是一个例子:
layout_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>