Java 在一个片段中覆盖两个布局
我想在布局A的顶部有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
布局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
作为背景,并在其顶部显示另一个视图。