Setting cursor to the right on an EditText with HI

2019-02-25 16:14发布

Is this possible? Any EditText attribute to do so?

Thanks.

2条回答
劳资没心,怎么记你
2楼-- · 2019-02-25 16:33

You can use

android:ellipsize="end"
android:gravity="center"

in your xml when you declare the EditText

The first line is to move cursor to the right and the second one to move the hint to the center. An example:

<EditText
    android:id="@+id/txt1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ellipsize="end"
    android:gravity="center"
    android:hint="@string/your_hint_id"
/>
查看更多
时光不老,我们不散
3楼-- · 2019-02-25 16:40

This should be the better solution and it worked for me.

<EditText 
android:layout_height="wrap_content" 
android:layout_width="wrap_content" 
android:text="1234" 
android:layout_weight="1" 
android:id="@+id/editText1" 
android:gravity="center_horizontal"></EditText>
查看更多
登录 后发表回答