标签和fragment内的内容重合了~这样真不好看哇
1. 原因:
因为TabHost继承FrameLayout,你在tabHost里面加TabWidget和FrameLayout ,这两个布局会有重叠
2. 解决方法:
把TabWidget和FrameLayout两个用一个布局包起来,再放到tabHost里
3. 正确代码:
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment
android:id="@+id/fragment_music_list"
android:name="com.example.activitylifecycle.activity.fragment.MusicListFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="@string/music_list" />
<fragment
android:id="@+id/fragment_play_list"
android:name="com.example.activitylifecycle.activity.fragment.PlayListFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="@string/play_list" />
<fragment
android:id="@+id/fragment_recent"
android:name="com.example.activitylifecycle.activity.fragment.RecentFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:tag="@string/recent" />
</FrameLayout>
</LinearLayout>
</TabHost>