[一] TextView

//Alt + ?实现代码的自动补全
//res/values/strings.xml  目录下面实现类似于c++的宏定义
<string name="hello">Hello  Notebook!!</string>

<TextView android:text="@string/hello" />//显示的是调用的内容
android:textSize="20sp" //字体大小用sp作为单位,宽度,高度用dp
android:textColor="#00FF00"//设置字体颜色为绿色
android:id="tv"  //定义控件的id

TextView tv=(TextView)findViewById(R.id.tv);
String str="欢迎大家!!这个是一个textview的演示!! ";
SpannableStringBuilder style=new SpannableStringBuilder(str);
style.setSpan(new ForegroundColorSpan(Color.RED), 0, 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
style.setSpan(new ForegroundColorSpan(Color.GREEN), 6, 21, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
style.setSpan(new ForegroundColorSpan(Color.BLUE), 21, 34, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
tv.setText(style);
//设置TextView的局部显示的颜色和显示的内容

设置超链:可以包括web的博客访问和phone num等。

android:autoLink="web" //设置web访问,同理phone等也可以有下滑线
//跑马灯效果
android:singleLine="true" //文字单行显示,不可缺
android:focusable="true"
android:ellipsize="marquee"
android:marqueeRepeatLimit="marquee_forever"
android:focusableInTouchMode="true"
View Code
原文地址:https://www.cnblogs.com/zhang1107/p/3092725.html