Mandar Sadye
Mandar Sadye

Reputation: 689

Android : How to change width of individual tabs in tab layout?

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.

Upvotes: 2

Views: 2297

Answers (1)

Abdelkader
Abdelkader

Reputation: 144

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);

Upvotes: 6

Related Questions