Android控件之Textiew的使用
16lz
2021-12-04
1、添加Textiew组件后修改其属性:
(1)XML文件修改:
android:textColor="#ff0000" //字体红色android:textSize="24sp" //字体大小android:textStyle="bold" //粗体
(2)修改java代码实现
TextView textView=(TextView)findViewById(R.id.text_view);//取得我们的TextView组件 textView.setTextColor(Color.RED);//设置成红色 textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24f);//设置成24sp textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));//加粗
2、Textiew超链接显示
(1)网站链接
xml中添加属性 android:autoLink="web" 即可,颜色自动变为蓝色
(2)电话号码链接:android:autoLink="phone"
(3)邮箱链接: android:autoLink="email"
(4)如果一个string含有多个超链接,则android:autoLink="all"。("\n"代表换行)
<string name="hello">我的博客地址是:http://flysnow.iteye.com \n我的电话是:400-34534-500\n我的email是12235@163.com android:autoLink="all"
3、长文本跑马灯形式显示:
android:ellipsize="marquee" android:focusable="true" android:marqueeRepeatLimit="marquee_forever" android:focusableInTouchMode="true" android:scrollHorizontally="true" android:singleLine="true"
4、限制行数
android:maxLines="2"
和
android:singleLine="true"
5、让textview为空时,不占空间
if(dynamic.getInfo()==null){ holder.dynamic_content.setVisibility(View.GONE); }else { holder.dynamic_content.setText(dynamic.getInfo()); }
Done!
转载于:https://www.cnblogs.com/xingyyy/p/3252764.html
更多相关文章
- android 5.1禁止休眠
- Android(安卓)Zxing修改为竖屏扫描,和连续扫描问题
- 关于Android(安卓)ListView组件中android:drawSelectorOnTop含义
- Android应用程序组件Content Provider的共享数据更新通知机制分
- 关于Android(安卓)ListView组件中android:drawSelectorOnTop含义
- Android(安卓)隐式调用 intent
- 完美解决android Studio打开报错 https://code.google.com/p/and
- android如何改变默认横竖屏方向
- Android定制之常见问题解决