textView without any default padding while increas

2019-02-19 18:40发布

问题:

This question already has an answer here:

  • Android: TextView: Remove spacing and padding on top and bottom 16 answers

I want to remove default padding on textView. when i increase the size of textView then it's padding size increases automatically. even i set background of text View as "@null". i just want to show only text without any padding. my View looks like this first images and i want to show like second images.

first image

second image

回答1:

Maybe this help you

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:padding="0dip"
        android:layout_margin="0dip"
        android:background="@android:color/transparent" />

Edit: Try this two attributes:

        android:maxWidth="...dip"
        android:maxHeight="...dip"


回答2:

Try android:includeFontPadding="false" or set the height as same as text size instead of "wrap_content"