Changing TextView padding in TabLayout

I want to change the text registration in TabLayout. I have a tab called "Subcategories". This is a line break into two lines. Is there any way to do this?

There are answers only regarding the old TabHost view, I am using TabLayout, used by the Google Material Design material library, using android.support.design.widget.TabLayout.

For TabHost: How to add a registration to a tab shortcut?

+4
source share
1 answer

The TextView is not padded, but the layout surrounding the text view is changed, so change the LinearLayout padding:

int tabIndex = 0;
LinearLayout layout = ((LinearLayout)((LinearLayout)mTabLayout.getChildAt(0)).getChildAt(tabIndex));
layout.setPadding(0, 0, 0, 0);
+6
source

All Articles