I have strange problem with TextView, it cuts off part of the text at the end. My layout looks like
Make use of these attributes
android:lines="1"
android:scrollHorizontally="true"
android:ellipsize="end"
will append "..." at the end. But this will not solve problem in honeycomb tab
So for honeycomb tablet add the following atttibute also
android:singleLine="true"
On the other hand if you require marquee effect
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:focusable="true"
android:focusableInTouchMode="true
If you expect differing lengths of text for your view or you're going to change the textSize
of different instances of your TextView
then you should use View.addOnLayoutChangeListener()
.
See an example here: https://stackoverflow.com/a/44069734/1402087
Yes there are some attributes you need to set, but first let us know what type of textview do you want exactly, single line or multi line?
There are some attributes you can take care of:
android:singleLine="true" // or false
android:ellipsize="marquee" // must check
android:lines="1"
You need to set android:minLines="2"
Set below properties in layout file. It works fine for me
android:singleLine="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
For me it I realised I was using the layout view of a different device to the one I was testing with. When I corrected this, I could see the textlayout was way too wide so I used this setting to reign it in:
android:layout_width="330dp"