How to make the text achieve merry effect, the following to achieve the next bar ~~~~~~
PackageIRDC. Scrollingtext;Importandroid.app.Activity;ImportAndroid.os.Bundle;ImportAndroid.widget.TextView; Public classScrollingtextextendsactivity{ PublicTextView T1; /**Called when the activity is first created.*/@Override Public voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.layout.main); T1=(TextView) Findviewbyid (R.ID.T1); T1.settext ("Haha my lantern program Next is the lyrics hehe: Chenyuluoyan, Biyuexiuhua, the United States of nowhere to hide, people in the side, such as Mu Spring"); T1.settextsize (30); T1.sethorizontallyscrolling (true); T1.setfocusable (true); }}
In this program I set the focus of T1 to true (meaning focus on T1), colleague I set the T1 text display can exceed its display area (T1.sethorizontallyscrolling (True) set the purpose of this line is to not let the program automatically to the text wrapping To make it a single line), and of course these attributes can be defined in the XML file. Next we look at the Main.xml file.
<?XML version= "1.0" encoding= "Utf-8"?><AbsolutelayoutAndroid:id= "@+id/widget35"Android:layout_width= "Fill_parent"Android:layout_height= "Fill_parent"Android:background= "@drawable/black"xmlns:android= "Http://schemas.android.com/apk/res/android"><TextViewAndroid:id= "@+id/t1"Android:layout_width= "100px"The width of the text display area This value must be smaller than the width of your text or it will be ineffective android:layout_height= "Wrap_content"Android:text= "@string/str_id"Android:textcolor= "@drawable/green"android:layout_x= "61px"android:layout_y= "69px"ANDROID:SCROLLX= "2px"Android:singleline= "true"android:ellipsize= "Marquee"Android:marqueerepeatlimit= "Marquee_forever"></TextView><viewstubandroid:layout_y= "221dip"android:layout_;wrap_content "Android:layout_x= "103dip"Android:id= "@+id/viewstub01"Android:layout_height= "Wrap_content"></viewstub></Absolutelayout>
It is noted that in TextView I added three lines of blue fields, where Singleline represents a single line of text in TextView if you set sethorizontallyscrolling in your program (TRUE) in this you can not write anymore, And then there's our key point. ellipsize= "Marquee" This statement indicates that we set the TextView to a merry, marqueerepeatlimit= "Marquee_forever" indicates the number of repetitions of the merry scrolling effect, You can fill in a natural number. All right, I got the build, try it.
Reprinted from: http://www.lupaworld.com/home/space-345712-do-blog-id-138560.html
How to set the horizontal scrolling effect in TextView in Androidui effects]android