BekaKK
BekaKK

Reputation: 2253

TextView: Remove spacing and padding on top and bottom

I have one textview which size is 50 dp. I got this result like the picture below.enter image description here
I want to remove bottom spaces in my textView ,because its height depend on the text size. And I want to receive background only into my quotation mark. Is there any way to remove the unused spaces in my textView?

<TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:gravity="top"
                android:text="“"
                android:fontFamily="@font/arialbd"
                android:background="#ff0"
                android:textColor="#E8E9EF"
                android:includeFontPadding="false"
                android:textSize="50dp" />

Upvotes: 1

Views: 4249

Answers (4)

Dr4ke the b4dass
Dr4ke the b4dass

Reputation: 1204

This solution works on my case. To remove bottom padding. Set the layout_height the same size as your textSize or 1dp or 2dp less.
Set includeFontPadding="false". Set android:lineSpacingExtra="0dp"

Upvotes: 1

mohamad sheikhi
mohamad sheikhi

Reputation: 394

Try this:

<TextView
    android:layout_width="wrap_content"
    android:layout_height="30dp"
    android:layout_gravity="top|center"
    android:text="“"
    android:fontFamily="@font/arialbd"
    android:background="#ff0"
    android:textColor="#E8E9EF"
    android:includeFontPadding="false"
    android:textSize="50dp"
    android:gravity="top" />

Upvotes: 1

Kaushal Panchal
Kaushal Panchal

Reputation: 1825

In your case you have to implement custom textView. check this example for reference.

Upvotes: 0

Adri&#225;n Galfioni
Adri&#225;n Galfioni

Reputation: 427

U can try setting your bottom margin to a negative value.

Something like this:

android:layout_marginBottom="-10dp"

Let me know if its works, that is the simplest way but can be anothers...

Upvotes: -1

Related Questions