Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在一个片段中覆盖两个布局_Java_Android_Android Layout_Android Fragments - Fatal编程技术网

Java 在一个片段中覆盖两个布局

Java 在一个片段中覆盖两个布局,java,android,android-layout,android-fragments,Java,Android,Android Layout,Android Fragments,我想在布局A的顶部有布局B。我想加入或合并这两个布局。在下图中,圆形的绿色和蓝色视图共享相同的布局,但它们被创建为不同的片段。roundedcolorFragment类扩展了SherlockFragment,并负责定制片段布局大小和形状。我的问题是我不能将two_片段布局放在two片段布局的顶部。我一直试图加入到roundedcolorfragment的onCreateView中。这就像覆盖了布局 twoFragments.xml <?xml version="1.0" encodin

我想在布局A的顶部有
布局B
。我想加入或合并这两个布局。在下图中,圆形的绿色和蓝色视图共享相同的布局,但它们被创建为不同的片段。
roundedcolorFragment
类扩展了
SherlockFragment
,并负责定制片段
布局
大小和形状。我的问题是我不能将
two_片段
布局放在
two片段
布局的顶部。我一直试图加入到
roundedcolorfragment
onCreateView
中。这就像覆盖了布局


twoFragments.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/twoFragments">
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/two_fragment" >
    <Button
        android:id="@+id/bbtnn"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />
</LinearLayout>
two_fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/twoFragments">
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:id="@+id/two_fragment" >
    <Button
        android:id="@+id/bbtnn"
        style="?android:attr/buttonStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />
</LinearLayout>


你写的是布局,但在你的图片上是片段。那么是布局还是片段呢?很抱歉,我搞糊涂了,一个片段需要
mView
和另一个视图相结合,以便在“onCreateView()”上显示
mView
作为背景,并在其顶部显示另一个视图。