How to set Tab width in Tab layout?

后端 未结 2 1624
时光说笑
时光说笑 2021-02-18 13:13

I\'m trying to create a tab layout which has two tabs. When I run the app on small mobile the tab layout looks fine but when I run the sam

相关标签:
2条回答
  • 2021-02-18 13:57

    Add this code in your tab_layout.xml

    <android.support.design.widget.TabLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:tabMaxWidth="0dp"
                app:tabGravity="fill"
                app:tabMode="fixed" />
    

    Hope it will works for you...

    0 讨论(0)
  • 2021-02-18 14:04

    You can create a tab layout where each tab has a custom View and add that tab in the tablayout with whatever size of your choice

    View customView = LayoutInflater.from(getContext()).inflate(R.layout.tab_text, null); 
    
    addTab(newTab().setCustomView(customView))
    
    0 讨论(0)
提交回复
热议问题