user3265784
user3265784

Reputation:

Edittext - Move Start of Text

enter image description here

In this edittext I use, text written on it starts too left. How can I make it so it is moved more to the right? And... what is that black cursor at the left? It disappears for some reason if I set gravity to the center. Thanks a lot

<EditText
    android:layout_width="300dp"
    android:layout_height="40dp"
    android:id="@+id/editText"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="60dp"
    android:hint="@string/hint_1"
    android:background="@drawable/shape" />

Upvotes: 0

Views: 177

Answers (4)

Aniruddha
Aniruddha

Reputation: 4487

Use padding

android:paddingLeft = "5dp"

Upvotes: 0

harveyslash
harveyslash

Reputation: 6012

You can set position by:

editText.setSelection(position)

so, to go to the beginning , use editText.setSelection(0);

Upvotes: 1

Piyush
Piyush

Reputation: 18933

If you want to move right then you can use

android:paddingLeft="10dp"

Upvotes: 0

Shabbir Dhangot
Shabbir Dhangot

Reputation: 9121

You can set position bye

editText1.setSelection(position)

May this will work

Another

etmsg.setText("test");
int position = etmsg.length();
Editable etext = etmsg.getText();
Selection.setSelection(etext, position);

Where etmsg is your Edittext

Upvotes: 1

Related Questions