All the online checks are not available. Or did you try it out by yourself ...
Test machine version: 4.0.3
There are articles on the internet saying to add Addstatesfromchildren
Measured: no addition to normal scrolling
Android:focusable= "true"
Measured: Must be added in XML. Use Tv.setfocusable (TRUE) in your program;
<LinearLayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"Android:addstatesfromchildren= "true"android:orientation= "vertical" > <TextViewAndroid:id= "@+id/tv"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:ellipsize= "Marquee"android:focusable= "true"Android:focusableintouchmode= "true"Android:marqueerepeatlimit= "Marquee_forever"android:scrollhorizontally= "true"Android:singleline= "true"Android:text= "11adshfkalhafklajfhkadjfhakjfhdjkfhadfjkhasdfhasdfjkhashkadjfhakjfhdjkfhadfjkhasdfhasdfjkhashkadjfhakjfhdjkfhadfjkh Asdfhasdfjkhashkadjfhakjfhdjkfhadfjkhasdfhasdfjkhashkadjfhakjfhdjkfhadfjkhasdfhasdfjkhasdjkfhsdakfhasdjkfhasdkfhsajkdfhsd Fhsadfkjhsaf " /> <ButtonAndroid:id= "@+id/xinle"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Sad" /></LinearLayout>
Click button to toggle mode
Findviewbyid (R.id.xinle). Setonclicklistener (new View.onclicklistener () { @Override Public void OnClick (View v) { =! Flag; if (flag) { textview.setellipsize (TextUtils.TruncateAt.valueOf ("END")); return ; } Textview.setellipsize (TextUtils.TruncateAt.valueOf ("MARQUEE"));} );
About the use of the Ellipsize parameter
in XML
Android:ellipsize = "End" ellipsis at the end
Android:ellipsize = "Start" ellipsis at the beginning
Android:ellipsize = "Middle" ellipsis in the middle
Android:ellipsize = "Marquee" marquee
It's best to add a constraint Android:singleline = "true"
Of course, you can also use code statements
Tv.setellipsize (TextUtils.TruncateAt.valueOf ("END"));
Tv.setellipsize (TextUtils.TruncateAt.valueOf ("START"));
Tv.setellipsize (TextUtils.TruncateAt.valueOf ("Middle"));
Tv.setellipsize (TextUtils.TruncateAt.valueOf ("MARQUEE"));
It is best to add a constraint tv.setsingleline (true);