2.TextView控件
来源:互联网 发布:软件管家桌面整理软件 编辑:程序博客网 时间:2024/06/10 23:30
创建方法:1、程序中创建
{
TextView tv = new TextView(this);
tv.setText("你好");
setContentView(tv);
}
2、XML布局文件中使用
<TextView
android:id="@+id/tv" //findViewById
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="你好" />
控件属性:设置字体大小推荐使用sp作为单位
设置宽度或高度等属性时推荐使用dp(dip)作为单位
android:textColor
Html类型:tv.setText(Html.fromHtml("this is a test for <font color=blue>my android</font>"));
String str = "this is a test for my android";
SpannableStringBuilder style = new SpannableStringBuilder(str);
style.setSpan(new ForegroundColorSpan(Color.RED), 0, 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);//不包括起始和终止
style.setSpan(new ForegroundColorSpan(Color.GREEN), 6, 10, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
style.setSpan(new ForegroundColorSpan(Color.BLUE), 10, 15, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
tv.setText(style);
超级链接:(none/web/email/phone/map/all)
android:autoLink="all"
跑马灯效果:android:singleLine="true" //单行显示
android:focusable="true" //控件能够获取焦点
android:ellipsize="marquee" //设置当文字过长时,该控件该如何显示,start/end/middle标志省略号的位置,marquee以跑马灯的效果显示
android:marqueeRepeatLimit="marquee_forever"//在ellipsize指定为marquee的情况下,设置重复滚动的次数,marquee_forever为无限次
android:focusableInTouchMode="true"//是否在触摸模式下获得焦点
- 2.TextView控件
- 2.常用控件:TextView
- TextView控件
- TextView控件
- TextView控件
- TextView控件
- TextView控件
- 控件:TextView
- TextView控件
- android控件之Textview
- android TextView控件
- TextView控件学习
- Android Textview控件
- 控件TextView的用法
- TextView控件属性列表
- android TextView控件
- android控件之TextView
- android控件:TextView属性
- system , DOS 命令
- 数据库笔记4
- Wormholes
- linux进程间通信--socket套接字
- Linux系统之间免密登录
- 2.TextView控件
- 第一次接触C语言
- java构造字符串
- uva 507Jill Rides Again(最长子串和)
- JavaBean的应用
- 科大讯飞发布四川话语音识别技术,号称识别准确率超过85%
- float 变量在内存当中的存放形式
- 九度OJ 1029 魔咒词典
- C++错误 LINK : fatal error LNK1168: cannot open Debug/ling.exe for writing