Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change the padding of TextView in TabLayout

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?

like image 660
apollow Avatar asked Jul 08 '15 04:07

apollow


1 Answers

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);
like image 124
apollow Avatar answered Oct 30 '22 04:10

apollow