Mainactivity.java:
Import Android.app.activity;import android.content.intent;import android.graphics.color;import android.os.Bundle; Import Android.text.html;import Android.text.spannablestring;import Android.text.spanned;import Android.text.method.linkmovementmethod;import Android.text.style.backgroundcolorspan;import Android.text.style.clickablespan;import Android.text.style.foregroundcolorspan;import Android.text.style.strikethroughspan;import Android.text.style.stylespan;import Android.text.style.TypefaceSpan; Import Android.text.style.urlspan;import Android.text.style.underlinespan;import Android.view.menu;import Android.view.menuitem;import android.view.view;import android.widget.textview;/* * android:ellipsize = "End" ellipsis at the end of an Droid:ellipsize = "Start" ellipsis at the beginning android:ellipsize = "Middle" ellipsis in the middle android:ellipsize = "marquee" Marquee set the number of scrolls Andro Id:marqueerepeatlimit= ""; android:marqueerepeatlimit= "marquee_forever" means scrolling all the time. */public class Mainactivity extends Activity {@Overrideprotected void oncrEate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); TextView textview1;textview1 = (TextView) Findviewbyid (R.ID.TEXTVIEW1); String Text = "1, backgroundcolorspan background color 2, Clickablespan text clickable, have click event 3, Foregroundcolorspan text color (foreground color) 4, Maskfilterspan Decorative effects, such as Blur (Blurmaskfilter), Emboss (Embossmaskfilter) 5, Metricaffectingspan parent class, generally not 6, rasterizerspan grating effect 7, Strikethroughspan Strikethrough (underline) 8, Suggestionspan equals placeholder 9, Underlinespan underscore 10, Absolutesizespan absolute size (text font) 11, Dynamicdrawablespan sets the picture, based on the text baseline or bottom alignment. 12, Imagespan picture 13, Relativesizespan relative size (text font) 14, Replacementspan parent class, generally not 15, Scalexspan based on x-axis scaling 16, Stylespan font style: bold, Italics, etc. 17, subscriptspan subscript (the mathematical formula will be used) 18, Superscriptspan superscript (mathematical formula will be used) 19, Textappearancespan text appearance (including font, size, style and color) 20, Typefacespan text Font 21, urlspan text HYPERLINK "; Charsequence charsequence = html.fromhtml (text); Textview1.settext (charsequence); Textview1.setmovementmethod ( Linkmovementmethod.getinstance ());}}
Activity_main.xml:
<linearlayout xmlns:android= "http://schemas.android.com/apk/res/android" xmlns:tools= "http// Schemas.android.com/tools "android:layout_width=" fill_parent "android:layout_height=" Fill_parent "Android:orienta tion= "vertical" android:paddingbottom= "@dimen/activity_vertical_margin" android:paddingleft= "@dimen/activity_ Horizontal_margin "android:paddingright=" @dimen/activity_horizontal_margin "android:paddingtop=" @dimen/activity_ Vertical_margin "tools:context=" com.example.textviewdemo0.MainActivity "> <textview android:id=" @+id/te Xtview1 "android:layout_width=" wrap_content "android:layout_height=" Wrap_content "android:ellipsize=" Marquee "android:marqueerepeatlimit=" Marquee_forever "android:singleline=" true "android:focusable=" tr UE "Android:focusableintouchmode=" true "android:textsize=" 50SP "/></linearlayout>
Android------textview for a marquee effect