2

I am trying to resize notification tab at the start of tab layout as in image,

enter image description here

Till now I am able to bring all three tabs as in image except the width. My progress till now is as follow,

enter image description here

So my question is, how do I resize individual items in a tab layout? I searched on many pages and tried reading the documentation but didn't find anything useful.

Thank you in advance.

Kishan Viramgama
  • 893
  • 1
  • 11
  • 23
Mandar Sadye
  • 689
  • 2
  • 9
  • 30

2 Answers2

4

This is late but better late than never. Also I can't see how Parth Patel answer is even related to this question. Have a look at this, you will find what you are looking for.

LinearLayout layout = ((LinearLayout) ((LinearLayout) tabLayout.getChildAt(0)).getChildAt(YOUR_TAB_NUMBER));
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) layout.getLayoutParams();
layoutParams.weight = YOUR_WEIGHT; // e.g. 0.5f
layout.setLayoutParams(layoutParams);
Abdelkader
  • 96
  • 5
0

You can use try this TabLayout.

layout.xml file

  <android.support.design.widget.TabLayout
        android:id="@+id/tabCauses"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:tabGravity="fill"
        app:tabMode="scrollable"
        app:tabSelectedTextColor="@color/white"
        app:tabTextAppearance="@style/MyCustomTextAppearance" />

style.xml file

  <style name="MyCustomTextAppearance" parent="TextAppearance.Design.Tab">
    <item name="textAllCaps">false</item>
    <item name="android:background">#FF26221E</item>
    <item name="android:fontFamily">@font/montserrat_semibold_1</item>
</style>
Parth Patel
  • 859
  • 2
  • 11
  • 28