Adjust the height between the Tablayout title text and the icon

Is there a way to reduce the distance between the title text and the TabLayout icon, as in Google Plus, where the icons and text name have at least a distance. I searched, but still could not find.

enter image description here

EDITED

This is how I set the icon and name:

  tabLayout.getTabAt(3).setIcon(R.drawable.ic_more_horiz_white_24dp); tabLayout.getTabAt(3).setText("More"); 

And this is my TabLayout :

 <android.support.design.widget.TabLayout android:id="@+id/tabs" android:layout_width="match_parent" android:layout_height="wrap_content" app:tabIndicatorColor="@color/white" app:tabIndicatorHeight="2dp" app:tabTextAppearance="?android:attr/textAppearanceSmall" /> 
+8
android material-design android-tablayout
source share
1 answer

TabLayout was introduced to help developers meet Material Design standards. In this case, this is the corresponding tab height, the indent between the icon and text and the icon and text size. Check out the Material Design Guide to familiarize yourself with them.

However, if you really do not like the filling (and you do not want to create the application in accordance with the recommendations for the design of materials), you can change it.

You can use @ user13 answer . That way you can convey your layout.

However, remember that if you want to build TabLayout more dynamically and use its TabLayout.Tab#setText(java.lang.CharSequence) and TabLayout.Tab#setIcon(int) you should use this layout:

 <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@android:id/icon"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="0" android:id="@android:id/text1" android:gravity="center" android:layout_below="@android:id/text1" /> 

Look at the identifiers @android:id/icon and @android:id/text1 . If you add these IDs, TabLayout your layout will work with the TabLayout class. See the documentation for more information.

+3
source share

All Articles