android中常用的控件一TextView
来源:互联网 发布:阿里云怎么退款 编辑:程序博客网 时间:2024/05/25 21:36
TextView是android中使用最多的控件之一,作用是用来显示字符串的组件,在手机上的效果就是屏幕上显示文字的一块区域。TextView类的继承关系如下
java.lang.Object
↳ android.view.View
↳ android.widget.TextView
TextView的XML常用属性,先上一张效果图
在手机上点击电话会调用手机上的电话功能,类似网址会调浏览器,邮件会调用邮箱功能
上面额效果图XML源码
<?xml version="1.0" encoding="utf-8"?><LinearLayout android:id="@+id/linearLayout01" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="match_parent" android:layout_width="match_parent" android:orientation="vertical" android:layout_gravity="center"> <!--显示超链接--> <TextView android:id="@+id/textView0" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#FF0000" android:textSize="18dip" android:background="#FFFFFF" android:text="拨打手机:13888888888" android:gravity="center_vertical|center_horizontal" android:autoLink="phone" /> <TextView android:id="@+id/textView1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#FF0000" android:textSize="18dip" android:background="#00FF00" android:text="Google搜索:http://www.google.com.hk" android:gravity="center_vertical|center_horizontal" android:autoLink="web" /> <TextView android:id="@+id/textView2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#FF0000" android:textSize="18dip" android:background="#FFFF00" android:text="发送邮件:10000000000@qq.com" android:gravity="center_vertical|center_horizontal" android:autoLink="email" /> <!--设置文字的滚屏--> <TextView android:id="@+id/textView3" android:layout_width="fill_parent" android:layout_height="20dp" android:textSize="18dip" android:ellipsize="marquee" android:focusable="true" android:marqueeRepeatLimit="marquee_forever" android:focusableInTouchMode="true" android:scrollHorizontally="true" android:text="文字滚屏文字跑马灯效果加长加长加长加长加长加长加长加长加长加长加长加长" android:background="#FF0000" android:textColor="#FFFFFF"> </TextView> <!--设置字符阴影--> <TextView android:id="@+id/TextView4" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="18dip" android:background="#69541b" android:textColor="#FFFFFF" android:text="设置字符串阴影颜色为绿色" android:shadowColor="#45b97c" android:shadowRadius="3.0" android:gravity="center_vertical|center_horizontal" /> <!--设置字符的外形--> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="18dip" android:background="#FFFFFF" android:textColor="#FF0000" android:text="设置文字外形为italic" android:textStyle="italic" android:gravity="center_vertical|center_horizontal" /></LinearLayout>
常用的XML 属性(省略前面的android:)
(none/web/email/phone/map/all)gravity设置文本位置background设置背景颜色textStyle设置字体,如微软雅黑,宋体,意大利斜体等,跟word文档字体选择类似。。。当然,这些内容也可以在java文件中动态设置
TextView类中的方法
TextView(Context context)
TextView(Context context,AttributeSet attrs)
TextView(Context context,AttributeSet attrs, int defStyle)
getText方法,获取TextView对象的文本
public CharSequence getText()length方法,获取文本的长度public int length()
0 0
- android中常用的控件一TextView
- Android中常用控件(1)-TextView
- [android]控件TextView的常用属性
- android 常用控件的使用 TextView EditTextView
- Android常用控件TextView的属性详解
- Android软件开发常用系统控件(一) TextView
- Android控件TextView学习一
- Android控件TextView学习一
- Android基本常用控件的介绍TextView EditText Button Menu
- Android第四讲——常用的基本控件(一)TextView、EditText、Button、RadioButton、CheckButton、ImageView
- android中TextView控件介绍
- android中常用的控件
- Android中常用的控件
- Android UI开发中的常用控件TextView
- Android常用控件(TextView-EditText-Shape-Selector)
- Android开发之四(一):常用控件之文本框TextView
- Android中TextView控件的跑马灯效果实现
- Android中TextView控件的singleLine废弃解决
- mysql group_cocnat()最大限制
- 编码惯例
- ArcGIS Desktop 高(新)版本数据库迁移到较低(旧)版本数据库操作方法
- fatal error LNK1112: 模块计算机类型“X86”与目标计算机类型“x64”冲突-解决
- 2016年4月21日百度笔试题--FirstInOutPage
- android中常用的控件一TextView
- 保留两位小数
- MAC下双开UNITY
- 如何在Windows系统安装pygame
- HDU1005
- Problem-1008
- eclipse、Android查看svn更新日志
- HTML5脚本扩展---新增小型API
- 二分查找,递归和非递归