Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CurrencyEditText setSelection problem #53

Open
yeulucay opened this issue Apr 17, 2019 · 5 comments
Open

CurrencyEditText setSelection problem #53

yeulucay opened this issue Apr 17, 2019 · 5 comments

Comments

@yeulucay
Copy link

Hi, I am trying to place the cursor rightmost position at the first focus. I get the content length correctly and call setSelection method. But doesn't work for me.

binding.cet.setSelection(binding.cet.getText().length()); // I call it on focus

@BlacKCaT27
Copy link
Owner

BlacKCaT27 commented Apr 17, 2019 via email

@yeulucay
Copy link
Author

First of all, thank you for your fast response. I aligned the text to the right position. And when I touch the input, the cursor is placed onto the 0 position (leftmost) and value changes different. Let me explain;
I will text 1,2,3. and it is expected to be $1.23 but,

  • $|0.00 (content aligned to right) I touched and cursor on the 0 position
  • $|10.00 here, cursor goes rightmost automatically $10.00|
  • $100.02|
  • $1000.23 final result.

@BlacKCaT27
Copy link
Owner

BlacKCaT27 commented Apr 17, 2019 via email

@yeulucay
Copy link
Author

I think, it works very well except one thing. The content text of the input is aligned left by default. So, when you touch (focus) to the input, the cursor takes place at the rightmost position by default. And after all changes, the input re-place the cursor to the end everytime. But only exception is, when you set gravity=end, it aligns the content text to the end of the input. And, when you touch (focus) the input, it places the cursor the the head.
I mean, you should align the cursor to the rightmost when the first focus.

<com.blackcat.currencyedittext.CurrencyEditText
android:id="@+id/ceCharge"
style="@style/EditTextStyle"
android:layout_width="match_parent"
android:layout_height="50dp"
android:gravity="end" !!!! HERE aligns content text to the end (this is what I need)
android:inputType="numberDecimal"
android:paddingStart="15dp"
android:paddingEnd="15dp"
android:textSize="20sp" />

@BlacKCaT27
Copy link
Owner

BlacKCaT27 commented Apr 17, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants