簡體   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