How to put margin inside an ANDROID STUDIO text box

Asked

Viewed 65 times

0

Hello! I wanted to add borders inside my Edittext, however, what is typed is well glued with the outline. I want to put a kind of padding or margin to give distance between the edge and the text.

Code of form:

<size
    android:height="40dp" />
<stroke
    android:color="#000"
    android:width="0.5dp"/>

Edittext code:

<EditText
        android:background="@drawable/shape"
        android:id="@+id/editTextTextPersonName"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="19dp"
        android:layout_marginRight="29dp"
        android:inputType="textPersonName"
        android:hint="Digite seu nome" />

How are you:

inserir a descrição da imagem aqui

1 answer

1


Then you have to apply a padding and not a margin.

Margin - Puts the view in relation to the surrounding elements.

Padding - Positions the view content relative to it

The same shall apply to android:gravity and android:layout_gravity.
This reply shows the difference between the two.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.