Actionbar tabs don't fill the tabbar

前端 未结 3 877
隐瞒了意图╮
隐瞒了意图╮ 2021-01-12 01:23

After hours of trying I finally found a method to separate the actionbar tabbar from the actionbar manualy. actionbar convert tabs to list navigation if there is no room But

相关标签:
3条回答
  • 2021-01-12 01:32

    Try to switch the parent. If that doesn't work try visiting this post: Stacked ActionBar tab bar not filling parent

    Good luck :)

    0 讨论(0)
  • 2021-01-12 01:32

    Use the following to customize the tabs in action bar:

    <style name="MyAppActionBarTabStyle" parent="@android:style/Widget.ActionBar.TabView">
        <item name="android:background">@drawable/actionbar_tabindicator</item>
        <item name="android:minWidth">40dip</item>
        <item name="android:maxWidth">40dip</item>
        <item name="android:layout_width">0dip</item>
        <item name="android:layout_weight">1</item>
    </style>
    

    Make sure that the activity where you are setting these navigation tabs has the following in its @android:theme

    <style name="MyAppTheme" parent="android:style/Theme.Holo.Light">
        <item name="android:actionBarTabStyle">@style/MyAppActionBarTabStyle</item>
    </style>
    

    I still could not figure how how to detect whether the tabbar is separate i.e. below main action bar or merged (when in landscape OR larger screens even in portrait)

    Another interesting thing to know is how to prevent tab bar from collapsing to a spinner when space is not enough.

    As and when I find out answers to my questions above, will update the post. Until then hope the styles help few other ppl

    0 讨论(0)
  • 2021-01-12 01:40

    I just solved this problem today.
    They key was using <item name="android:padding">0dp</item> like so...

    <style name="MyActionBar"
        parent="@android:style/Widget.Holo.Light.ActionBar">
    </style>
    
    <style name="LoginActionBar"
        parent="@style/MyActionBar">
        <item name="android:actionBarTabStyle">@style/LoginActionBarTabs</item>
    </style>
    
    <style name="LoginActionBarTabs"
        parent="@android:style/Widget.Holo.ActionBar.TabView">
        <item name="android:padding">0dp</item>
    </style>
    

    You don't need that many styles, but I didn't want to take any chunks out, which may have lead to confusion.

    I also see that you already worked around this, but I figured I'd add my answer for the next person to come looking for this.

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