Android textview gravity center

I have this layout:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#222222"
    android:gravity="center_horizontal"
    android:layout_gravity="center_horizontal"
    android:paddingBottom="5dp">
    <SeekBar
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:id="@+id/seekbar"
        android:max="5"
        android:progress="2">
   </SeekBar>
      <TextView android:id="@+id/fontsize00" 
        android:layout_width="25dp" 
        android:layout_height="25dp"
        android:gravity="center"
        android:layout_marginLeft="20dp"
        android:text="C"
        android:textSize="20dp"
        android:background="#FFFFFF"
        android:textColor="#222222">
   </TextView>

</LinearLayout>  

      

The text size changes as the counter value changes. Even if low values ​​place the text in the center of the text, high values ​​set it lower. Why is this happening? enter image description here

+3


source to share


2 answers


Perhaps this is because you are manually setting the android:layout_height

layout. Try changing it to wrap-content

.



And TextView

, as you probably know, it has some other filling methods. Where can you install the special add-on.

0


source


This is caused by font filling. The text inside the TextView frame is laid out according to the add-on for ascenders and descenders. Font indentation can be disabled by setting the TextView widget attribute:



android:includeFontPadding="false"

      

+7


source







All Articles