Th0rgal
Th0rgal

Reputation: 939

How to define horizontal padding of a TextView with android < 8

I am working on a small application for android 6+ with a chat interface using material design. I'm using a text view in order to represent the text but I need to set the padding in order to get something not too ugly.

enter image description here

But the problem is that I can't use android:paddingHorizontal with android <8, do you know an alternative?

Upvotes: 0

Views: 1266

Answers (1)

Andr&#233; Sousa
Andr&#233; Sousa

Reputation: 1730

You can use paddingLeft and paddingRight.

You code will look like this:

<TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/message_body"
            android:layout_below="@+id/name"
            android:layout_alignStart="@+id/name"
            android:background="@drawable/andrew_message"
            android:paddingTop="4pt"
            android:paddingBottom="4pt"
            android:paddingLeft= "14dp"
            android:paddingRight="14dp"
            android:elevation="0dp"
            android:textSize="18sp"
            android:text="@string/fake_text"
            android:textColor="@color/theirMessagesTextColor" android:fontFamily="@font/product_sans_regular"/>

Upvotes: 2

Related Questions