I customized tab layout for tab activity in my Android app. The problem is how to center it vertically. The text is centered horizontally automatically. I tried writing gravity:center
, layout_gravity:center
. Even more: I tried writing exact height in my TextView
, but nothing works (actually exact pixels work great, but when I change device orientation - text is not centrally oriented.
That's my code for tab layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tab_name"
android:paddingTop="11dp"
android:paddingBottom="11dp"
android:layout_width="match_parent"
android:textSize="14dp"
android:textStyle="bold"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:maxLines="1"
android:layout_gravity="center" />
</LinearLayout>
Here's screenshot of my problem: