Change the Hint's gravity - EditText

0

In the xml of my edittext I put the gravity property to leave the cursor always at the end, however I needed to leave the text hint at the beginning. Is it possible to set a gravity property for the text and another property for the hint? Here is the xml code from my EditText:

<EditText
                android:id="@+id/txtHorimetro"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textColorHint="#000000"
                android:inputType="numberDecimal"
                android:hint="Horimetro *"
                android:textSize="20sp"
                android:gravity="right"
                android:layout_marginTop="20dp"
                android:layout_below="@+id/txtLitros"
                android:layout_alignStart="@+id/txtLitros"
                android:layout_alignEnd="@+id/txtLitros" />
    
asked by anonymous 17.10.2017 / 17:00

1 answer

2

Matheus,

For the text, you can use setSelection , for example:

EditText editText = (EditText)findViewById(R.id.edittext_id);
editText.setSelection(editText.getText().length());

In this way Java will check the text that is typed in the field, and will place the cursor after the last character.

    
17.10.2017 / 17:05