-
Notifications
You must be signed in to change notification settings - Fork 868
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
setText(.., ...) doesn't call "invalidate()" #65
Comments
Hey, these feature works fine on my phone in Demo project. Could you provide your layout to me? |
It works fine in most of the standard scenarios, but in my case, I am adding a countdown to the switch and updating the text (which is the remaining time) with a Basically, I want to refresh the text of the Concerning the second issue (text not centered if different from the initial one) here's a screenshot of what it looks like: I set the initial text o an empty string, and then updated the text to "0:00 left". You can see that it is not centered anymore, because the text keep the same initial positionas when it was an empty string. |
I've fixed these problem and pushed to branch fix_65. Could you please check out that branch and see whether the problem has been solved? Waiting for your reply. |
Thanks for the quick fix! EDIT:There is a one thing that seems to be still buggy:
|
I've upload the library and you can use the newest version 1.4.4 with Gradle. I changed the logic of positioning text and add a new attribute "kswAutoAdjustTextPosition". The new logic will make text looks centered when there are round corners. You can set this attribute to false when at special situation. |
Hey, I thought everything was fine, but I played with a bigger track width and the text is again uncentered. You can reproduce it by, for example, doubling the I tried playing with |
margins are recomputed only when text does not fit into the size of the current layout but we also need to recompute margins for text when size of the text is smaller than or equal to the size of the current layout to center it properly. Solved with help and magic from @julienbiral |
When setting the text in code, invalidate() isn't called (just requestLayout()), which doesn't redraw the text. I would suggest calling both invalidate() and requestLayout(), as explained here: Why is requestLayout being called directly after invalidate?
Also, if I set a text with xml attributes (kswTextOn), the text will be centered. Now, if I update the text in code, the text will keep the position of the initial text and won't look great.
The text was updated successfully, but these errors were encountered: