TabHost布局需注意

 

标签和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>


 

  


 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值