Reputation: 1250
I want to change the padding on the textview in the TabLayout. I have a tab that's called Subcategories. This is breaking line wrapping into two lines. Is there a way to do this?
There are answers only concerning the old TabHost view, I am using the TabLayout used by Google's Material Design library using android.support.design.widget.TabLayout.
For TabHost: How to add padding to a tabs label?
Upvotes: 5
Views: 4189
Reputation: 1250
The TextView is not padded out, but the layout surrounding the textview is, so change the LinearLayout's padding:
int tabIndex = 0;
LinearLayout layout = ((LinearLayout)((LinearLayout)mTabLayout.getChildAt(0)).getChildAt(tabIndex));
layout.setPadding(0, 0, 0, 0);
Upvotes: 6