Reputation: 159
I have set
android:gravity="right"
to align my text to the right.
However, when the length of the string exceeds the space, the following text can't be seen.
How can I solve this, so that the previous entry will move leftwards?
It appears that the problem of my code comes from EditText.append()
, when I append the new input from the OnClickListener, the text would behave the way keyboard input does.
May you guide me how to solve it? Sorry I am new to Android
<EditText
android:id="@+id/equation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="40dp"
android:ems="10"
android:focusable="false"
android:focusableInTouchMode="false"
android:inputType="numberSigned|numberDecimal"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:clickable="false"
android:gravity="right"
android:layout_gravity="end"/>
// Image
The Edit text widget is right aligned.
When the length of the string exceeds the space, the new entry can't be seen.
How to change it so that the old entry move leftwards, and the new entry will continue appear at the right end of the edit text widget?
Upvotes: 1
Views: 868
Reputation: 23881
try this:
<EditText
android:id="@+id/equation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:scrollHorizontally="true"
android:ellipsize="end"
android:layout_marginEnd="16dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="40dp"
android:ems="10"
android:focusable="false"
android:focusableInTouchMode="false"
android:inputType="numberSigned|numberDecimal"
android:clickable="false"
android:gravity="right">
</EditText>
Upvotes: 1
Reputation: 2458
Just add this property into your EditText
android:layout_alignParentRight="true"
this property supports all the android versions. Although @pail kanti also right but android:textDirection="anyRtl"
support API level 17 and above
thank you.
Upvotes: 5
Reputation: 1610
Just add this to your EditText:
android:textDirection="anyRtl"
This will solve your problem.
Upvotes: 1