Tab not taking full width on Tablet device [Using android.support.design.widget.TabLayout]

前端 未结 12 2087
萌比男神i
萌比男神i 2020-11-28 17:39

I have setup tabs as UPDATE 29/05/2015 this post. Tabs take full width on my Nexus 4 mobile but on nexus 7 tablet it in center and not cover full screen wid

12条回答
  •  清酒与你
    2020-11-28 18:21

    I had the same problem and I checked the TabLayout style, and i found that its default style is Widget.Design.TabLayout which has different implementations (normal, landscape and sw600dp).

    The one we need is the one for tablets (sw600dp) which has the following implementation:

    
    

    From this style we will use "tabGravity" (which possible values are "center" or "fill") using the "fill" value.

    But we need to go deeper, and then we see that this one extends from Base.Widget.Design.TabLayout, which implementation is:

    
    

    So, from this style we will need to override "tabMaxWidth". In my case I set it to 0dp, so it has no limit.

    And my style looked like this:

    
    

    And then the tab bar will fill the whole screen from side to side.

提交回复
热议问题