Android控件的常用控件:
文本控件:1.TextView(显示文本的控件 )
android:text 设置文本框文本的内容
android:autoLink 是否将符合指定格式的文本转换为可单击的超链接形式(取值范围:none|web|email|
phone|map|all)
android:singleLine 为true文本框不会换行
android:lines 默认占几行
android:minLines 最少占几行
android:textColor 字体颜色
android:textSize 字体大小
android:textStyle 字体风格如粗体 斜体等
android:background 设置背景,可以是图片也可以是颜色
android:typeface 字体 android系统默认支持三种字体,要是使用其它字体,需要把字体(.tff)放在
assets/fonts目录下,然后用代码设置(代码:1.Typeface typeface=Typeface.createFromAssets(),"fonts/FZTK.TTF")
;2.textView.setTypeface(typeface);
android:ellipsize 文本超过TextView的长度是如何处理(取值范围none|start|middle|end|marquee)如果取
值为marquee需要加上三个属性
①android:focusable="true"②android:focusableInTouchMode="true"③android:clickable="true" ,marquee默认为无
限循环,可以通过android:marqueeRepeatLimit="1"设置循环次数
android:drawableXX 设置文本的icon
2.EditText(编辑文本的控件)
EditView是TextView的子类
android:password 密码框
android:phoneNumber 电话号码框
android:inputType="" 以上两种为过时写法,推荐使用这种
android:textColorHighlight 文字被选中时的背景颜色
android:hint 提示字符信息
Android资源:所谓资源都是指在res文件夹下的xml文件,每一种类型的xml文件都对应了一种资源
外形资源(shape): Shape资源用于定义一个基本的几何图形(矩形,圆形,线条等)
属性:android:shape 取值:rectangle矩形 oval椭圆 line直线 ring圆
<corners/>定义几何图形四个角的弧度①android:radius 设置四个角的弧度
②android:XXXradius 设置某一个角的弧度
<gradient/>定义使用渐变颜色填充①android:startColor开始颜色
②android:centerColor中间颜色
③android:endColor结束颜色
④android:angle方向角度 取值必须是45的整倍数(0从左往右,
90从上往下)
⑤android:type渐变的类型 取值:linear线性渐变 radial径向
渐变 一定要指定android:gradlientRadius属性
⑥android:gradlientRadius径向渐变的范围
<padding/>定义几何形状的内边距
<size/>定义几何形状的大小
<solid/>定义使用单种颜色填充 android:color
<stroke/> 定义几何形状的边框 ①android:width边框的宽度
②android:color边框的颜色
③android:dashWidth虚线的宽度
④android:dashGap虚线的间距
尺寸资源(Dimension)dimen标签用于定义尺寸资源<dimen name=""></dimen>
颜色资源(Color):color标签用于定义尺寸资源<color name=""></color>
Selector选择器: 作用:在控制控件在不同状态下的样式
<item/>①android:state_focused=""控件的状态 获取焦点状态的资源,必须放在第一行
②android:drawable="" 设置对应的资源或者图片
文本控件:1.TextView(显示文本的控件 )
android:text 设置文本框文本的内容
android:autoLink 是否将符合指定格式的文本转换为可单击的超链接形式(取值范围:none|web|email|
phone|map|all)
android:singleLine 为true文本框不会换行
android:lines 默认占几行
android:minLines 最少占几行
android:textColor 字体颜色
android:textSize 字体大小
android:textStyle 字体风格如粗体 斜体等
android:background 设置背景,可以是图片也可以是颜色
android:typeface 字体 android系统默认支持三种字体,要是使用其它字体,需要把字体(.tff)放在
assets/fonts目录下,然后用代码设置(代码:1.Typeface typeface=Typeface.createFromAssets(),"fonts/FZTK.TTF")
;2.textView.setTypeface(typeface);
android:ellipsize 文本超过TextView的长度是如何处理(取值范围none|start|middle|end|marquee)如果取
值为marquee需要加上三个属性
①android:focusable="true"②android:focusableInTouchMode="true"③android:clickable="true" ,marquee默认为无
限循环,可以通过android:marqueeRepeatLimit="1"设置循环次数
android:drawableXX 设置文本的icon
2.EditText(编辑文本的控件)
EditView是TextView的子类
android:password 密码框
android:phoneNumber 电话号码框
android:inputType="" 以上两种为过时写法,推荐使用这种
android:textColorHighlight 文字被选中时的背景颜色
android:hint 提示字符信息
Android资源:所谓资源都是指在res文件夹下的xml文件,每一种类型的xml文件都对应了一种资源
外形资源(shape): Shape资源用于定义一个基本的几何图形(矩形,圆形,线条等)
属性:android:shape 取值:rectangle矩形 oval椭圆 line直线 ring圆
<corners/>定义几何图形四个角的弧度①android:radius 设置四个角的弧度
②android:XXXradius 设置某一个角的弧度
<gradient/>定义使用渐变颜色填充①android:startColor开始颜色
②android:centerColor中间颜色
③android:endColor结束颜色
④android:angle方向角度 取值必须是45的整倍数(0从左往右,
90从上往下)
⑤android:type渐变的类型 取值:linear线性渐变 radial径向
渐变 一定要指定android:gradlientRadius属性
⑥android:gradlientRadius径向渐变的范围
<padding/>定义几何形状的内边距
<size/>定义几何形状的大小
<solid/>定义使用单种颜色填充 android:color
<stroke/> 定义几何形状的边框 ①android:width边框的宽度
②android:color边框的颜色
③android:dashWidth虚线的宽度
④android:dashGap虚线的间距
尺寸资源(Dimension)dimen标签用于定义尺寸资源<dimen name=""></dimen>
颜色资源(Color):color标签用于定义尺寸资源<color name=""></color>
Selector选择器: 作用:在控制控件在不同状态下的样式
<item/>①android:state_focused=""控件的状态 获取焦点状态的资源,必须放在第一行
②android:drawable="" 设置对应的资源或者图片