Android常用控件

来源:互联网 发布:咏春拳教学软件 编辑:程序博客网 时间:2024/05/29 17:08

此文章适合初级学习Android常用控件的学员,如果文章中有不恰当的地方请指点

1.TextView(显示文本的控件)

其中常见属性有


android:text 设置文本框内文本内容

android:singleline  为true文本框不会换行

android:lines   默认占几行

android:minLines    最少占几行

android:textcolor   字体颜色

android:textsize  字体大小

android:textstyle 字体风格



2,EditText(编辑文本的控件)

EditView是TextView的子类

其中常见属性有

android:password  密码框

android:phoneNumber  电话框

android:inputType="" 以上使用两种为过时写法,推荐使用这种

android:textColorHighiht  文字被选中时的背景颜色

android:hint   提示文字



3.Shape外形资源

所谓的资源都是在res文件下的xml文件,每一种类型的xml文件都对应了一种资源。

属性:

android:shape

取值:

rectangle 矩形

oval  椭圆

line  直线

ring 圆环

子节点:

<corners/> 定义几何图形四个角的弧度   

android: radius 

android:xxxradius 设置某一个角的弧度


<gradient/>定义使用渐变颜色填充

android:startColor 开始颜色

android:centerColor 中间颜色

android:endcolor   结束颜色

<padding/>定义几何形状的内边距

<size/>定义几何形状的大小

<solid/>android:定义使用单种颜色填充 

<stroke/>定义几何形状的边框

android:width 边框宽度

android:color 边框颜色

android:dashwid 虚线宽度

android:dashGap 虚线间距


4.Selector选择器

作用:在控制控件在不同状态下的样式

<ltem/>android:state_focused="" 控件状态true获false

android:drawable=“” 设置对应的资源或者图片


原创粉丝点击