Jason Lie February 2016

Android EditText not writing from left to right

I've got a EditText which changes a Seekbar if the Text is being edited but it writes from right to left for some reason.

This is the way I do it

priceText.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable mEdit) {
        }

        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        public void onTextChanged(CharSequence s, int start, int before, int count) {
            priceSeekbar.setProgress(Integer.parseInt(priceText.getText().toString()));
        }
    });

XML

 <EditText
            android:id="@+id/priceAmount"
            android:layout_width="50dp"
            android:textSize="15dp"
            android:layout_height="22dp"
            android:background="@drawable/background_edittext"
            android:gravity="center"
            android:inputType="number"
        />

I think it's caused by

priceSeekbar.setProgress(Integer.parseInt(priceText.getText().toString()));

When I remove this line, it goes back to normal but I'm not sure why. Any ideas?

Answers


Avinash Joshi February 2016

try doing this

<EditText
     ...
     android:gravity="left"
     ...


joan February 2016

Try to set android:gravity="left"

Post Status

Asked in February 2016
Viewed 1,554 times
Voted 11
Answered 2 times

Search




Leave an answer