Android 安卓-内部定位元素<;合并/>;标签
Android 安卓-内部定位元素<;合并/>;标签,android,android-layout,Android,Android Layout,我刚刚了解了标记,我正试图定位它里面的元素,就像我在RelativeLayout容器中一样除了布局重力外,似乎没有任何东西在工作 我做错了什么 Thx预期通过使用工具名称空间,可以找到一种解决方法 您需要创建第二个布局文件,如下所示: <!-- linear.xml --> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation=
我刚刚了解了
标记,我正试图定位它里面的元素,就像我在RelativeLayout
容器中一样除了布局重力外,似乎没有任何东西在工作
我做错了什么
Thx预期通过使用
工具
名称空间,可以找到一种解决方法
您需要创建第二个布局文件,如下所示:
<!-- linear.xml -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include layout="@layout/merged"/>
</LinearLayout>
这样,项目将像一个
LinearLayout
那样显示,同样的情况也适用于所有其他布局类型。Great@David,你建议的是像一个魔咒一样工作。。。现在有一个小问题:我使用的不是线性布局,而是RelativeLayout,在合并的子布局中,一切看起来都很好。问题是现在不起作用的是根布局本身(在示例linear.xml中)。我包括了3个布局,我试图以列表的方式定位它们,但是当我使用下面的布局时,什么都没有发生。我该怎么办?试着在include
标签上设置高度和宽度,但我不知道从头顶上可以找到什么解决方案。如果你不能让它工作,你应该打开一个新的问题与更多的细节。
<?xml version="1.0" encoding="utf-8"?>
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:showIn="@layout/linear"> <!-- HERE the fun stuff -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test"/>
</merge>