Android TabWidget空白问题

2022-01-09 00:00:00 xml tabs android java android-widget

我正在处理 TabWidget,并且在 TabActivity 和 Tabs 之间出现了一个空白.

I am working on the TabWidget and i am getting a white space between the TabActivity and the Tabs.

我不知道如何删除这个空白请任何人帮助我应该如何删除它,我的 tab_main.xml 如下:

I don't know how to remove this white space please can any one help me out how should i remove it, my tab_main.xml is as follows :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

<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" >

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="0dip"
            android:layout_weight="1" />

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="0" />
    </LinearLayout>
</TabHost>

我尝试将 TabWidget 的背景颜色设置为 android:color:transparent 但在 Activity 和 Tab 之间仍然存在相同的空白.

I tried to put background color of TabWidget to android:color:transparent but still same white space comes between the Activity and the Tab.

我不希望我的 Activity 和选项卡之间有任何分隔空间(可以这样做吗?)

I do not want any separation space between my Activity and the Tabs (Is it possible to do it?)

请任何人建议我如何摆脱这个空白.

Please can any one suggest me how to get rid of this white space.

推荐答案

看起来您遇到了与我在项目中遇到的类似问题,请查看 this 项目并尝试实现可绘制的 xml 文件并为您的 TabWidget 提供此项目中给出的特定自定义尺寸.它肯定对你有用.

It Look's Like you are having similar issue as i was having in my project, check out this project and try to implement the drawable xml files and provide your TabWidget with the specific custom dimensions as given in this project. It will surely work for you.

相关文章