效果
代码结构
在MainActivity中动态(用事物)添加LeftFragment和RightFragment
核心代码:
activity_main.xml:
<LinearLayout 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"
android:orientation="horizontal" >
<!-- 放LeftLeftFragment的布局 -->
<LinearLayout
android:id="@+id/left"
android:layout_weight="5"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#F5DEB3"
>
</LinearLayout>
<!-- 放RightFragment的布局 -->
<LinearLayout
android:id="@+id/right"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#FFB6