dividers between TabWidgets

前端 未结 5 1689
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-01 03:54

Is the android:divider attribute under the TabWidget working? I tried the Tab Layout tutorial from android just to test (http://developer.android.com/resources/tutorials/vi

相关标签:
5条回答
  • 2021-01-01 04:15

    I had the problem in ICS, where divider was visible. None of the solutions worked except for the following.

    <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:gravity="bottom"
                android:layout_alignParentBottom="true"
                android:fadingEdge="none"
                android:showDividers="none" >
            </TabWidget>
    

    Key line was android:showDividers="none"

    0 讨论(0)
  • 2021-01-01 04:22

    I removed divider line from tabbar with use of below magical lines.

      mTabHost.getTabWidget().setDividerDrawable(null);
    

    OR

      mTabHost.getTabWidget().setDividerDrawable(R.Color.transperant);
    
    0 讨论(0)
  • 2021-01-01 04:23

    I had this issue and solved it with the following code

    tabHost1.getTabWidget().setDividerDrawable(R.drawable.example1);
    if(Build.VERSION.SDK_INT >= 11)
        tabHost1.getTabWidget().setShowDividers(TabWidget.SHOW_DIVIDER_MIDDLE);
    

    For api levels below 11, it worked with the first line. For 11 and higher I included this to get this working. setShowDividers is added in linearlayout from api level 11. Hope this helps someone

    0 讨论(0)
  • 2021-01-01 04:27

    Having the same issue myself. I only see the problem in Ice Cream Sandwich (ICS / 4.0.x). In android 1.6 - 2.3.4 there is no issue, dividers show up properly when setting a drawable in code, or in the xml layout.

    I've tried just about everything I can think of to fix it but nothing works, including Josh's answer above :( though I have noticed that when setting any drawable as the divider, it will take up the space between tabs as if there was a drawable there, but it's just not visible.

    Hopefully that gives someone else a hint as to what could be happening..?

    0 讨论(0)
  • 2021-01-01 04:37

    It doesn't look like the divider attribute is available anymore for TabWidget. One way to add a custom divider is to set it programmatically:

    mTabHost.getTabWidget().setDividerDrawable(R.drawable.divider_vertical_dark);
    

    Make sure however, you call this before you set the content of the tabs. It would crash on me if I called it after.

    0 讨论(0)
提交回复
热议问题