AndroidのTextViewで高さと文字サイズを指定したとき、TextViewに対して文字が大きすぎると、gravity="center"やpadding="0dp"を指定していても文字が下に寄る(つまり上部に余白ができる)ことがある。
例えば以下のようなレイアウトを表示させると
例えば以下のようなレイアウトを表示させると
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="300dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:background="#dddddd"
android:gravity="center"
android:padding="0dp"
android:text="あいうえおjkl"
android:textAlignment="gravity"
android:textSize="40dp" />
</FrameLayout>