繁体   English   中英

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

[英]how to remove bottom space from tabwidgets in android

我试图从选项卡的底部删除空格。 屏幕截图

Here is my xml code.

我想删除选项卡绿色下方的空间。

在这里输入代码

                   <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:tabStripEnabled="false"

SO Post引用

尝试这些修改。 此代码取自具有标签的片段。

这是创建标签指示符视图的代码。

    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>

现在,这里重要的部分是LinearLayout中的android:background="@drawable/tabselector" 我的看起来像这样。

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

此tabselector.xml是您将@drawable/tab_pressed_light@drawable/tab_button_active@drawable/tab_unselected_light@drawable/tab_button_inactive

要么

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM