Reputation: 489
I have the following TextView
<TextView
android:id="@+id/cookieCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textColor="@android:color/black />
and I programatically update it to say this
cookieCount.text = """${vm.cookies} cookies"""
vm.cookies gets updated every second, and so does this code. Everything works fine, however once the cookies are 10 or above the "cookies" part of the string disappears leaving only the integer. What could be causing this and how can I fix this bug?
Upvotes: 1
Views: 45
Reputation: 1737
Try to set layout_width
to match_parent
and update the layout around to support it. Alternatively you could try to use ellipsize="end"
which will add the three dots at the end if entire text no longer fits in the measured width.
In any case it's bad for performance to have wrap_content
and update text periodically as this triggers a bunch of re-measuring under the hood.
Also: Why the triple double quotes when "${vm.cookies} cookies"
will do?
Upvotes: 1