Search code examples
androidcursorandroid-edittextgravity

Setting cursor to the right on an EditText with HINT Gravity to center


Is this possible? Any EditText attribute to do so?

Thanks.


Solution

  • 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"
    />