如何在android中删除tabwidgets的底部空间

如何在android中删除tabwidgets的底部空间,android,android-tabhost,fragment-tab-host,Android,Android Tabhost,Fragment Tab Host,我已尝试从选项卡底部删除空格。 我想删除标签绿色下方的空白 在这里输入代码 <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TabWidget

我已尝试从选项卡底部删除空格。

我想删除标签绿色下方的空白

在这里输入代码

                   <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_gravity="bottom"
                android:divider="@null"
                android:gravity="bottom"
                android:showDividers="none"
                android:tabStripEnabled="false" />
        </LinearLayout>

我搜索了这么多,但没有找到合适的解决方案

我想删除标签绿色下方的空白


欢迎提出建议

试试android:tabstripeenabled=“false”

引用自

试试这些修改。此代码取自具有选项卡的片段

下面是创建选项卡指示器视图的代码

    View indicator = LayoutInflater.from(getActivity()).inflate(R.layout.tab,(ViewGroup) mRoot.findViewById(android.R.id.tabs), false);
    TabSpec tabSpec = mTabHost.newTabSpec(tag);
    tabSpec.setIndicator(indicator);
    tabSpec.setContent(tabContentId);
您的选项卡指示器视图可能与此类似

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center"
    android:layout_weight="1"
    android:background="@drawable/tabselector"
    android:padding="5dp" >

    <ImageView
        android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/tab1icon"/>

</LinearLayout>
此tabselector.xml是您将
@drawable/tab_pressed_灯
与激活的
@drawable/tab_按钮
@drawable/tab_unselected_灯
交换的位置

您可以使用以下语句删除选项卡的底部条带和选项卡之间的分隔符

    TabHost t;
    t.getTabWidget().setStripEnabled(false);
    t.getTabWidget().setDividerDrawable(R.drawable.ic_launcher);

第二个注意事项是,如果tat不起作用,请尝试阅读此处接受的答案,尝试android:layout\u alignParentBottom=“true”我使用线性布局作为父布局,因此不能使用“android:layout\u alignParentBottom=“true”tab\u聚焦的\u light tab\u选定的\u light这些可绘制的内容是什么?您试图删除的空间称为导航指示器,您将添加的可绘制内容将是显示在选项卡标题背景中的图像。我已使用另一种方法编辑了我的答案,以隐藏该条带,将其添加到您的
onCreate()中
method.Sagar Pilkhwal。将在OnCreate()中添加什么?我在等你的回答;t、 getTabWidget().setStripEnabled(false);t、 getTabWidget().setDividerDrawable(R.drawable.ic_启动器)尝试将其添加到您的
onCreate()
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <!-- Non focused states -->
    <item
        android:state_focused="false"
        android:state_selected="false"
        android:state_pressed="false"
        android:drawable="@drawable/tab_unselected_light" />
    <item
        android:state_focused="false"
        android:state_selected="true"
        android:state_pressed="false"
        android:drawable="@drawable/tab_selected_light" />
    <!-- Focused states -->
    <item
        android:state_focused="true"
        android:state_selected="true"
        android:state_pressed="false"
        android:drawable="@drawable/tab_focused_light" />
    <!-- Pressed state -->
    <item
        android:state_pressed="true"
        android:drawable="@drawable/tab_pressed_light" />
</selector>
    TabHost t;
    t.getTabWidget().setStripEnabled(false);
    t.getTabWidget().setDividerDrawable(R.drawable.ic_launcher);