TextView

1、文本框(TextView)与编辑框(EditText)的功能和用法
TextView是直接继承了View,EidtText和Button两个组件的父类便就是View

TextView其实就是一个文本编辑器,只是android关闭了他的文字编辑功能

EidthView是一个可以编辑的文本编辑器

TextView:属性
(1)、textSize="20pt"   设置文本框内字体的大小
(2)、drawableEnd="@drawable/xxxx"  在文本框结尾处绘制指定的图像
(3)、ellipsize"middle"  设置显示的文本超过了定义的TextView的长度时,如何处理文本内容
(4)、singleLine="true"  设置改文本框是否为单行模式,如果设为true则文本框不会换行
(5)、atuoLink="email/phone"  是否将符合指定格式的文本转换成可单击超连接形式
(6)、shadowColor="#00f"   设置文本框内文本阴影的颜色
(7)、shadowDX="10.0"   设置文本框内文本的阴影在水平方向的偏移
(8)、shadowDY="8.0"   设置文本框内文本的阴影在垂直方向的偏移
(9)、shadowRadius="3.0"   设置该文本的阴影的模糊程度,该值越大,阴影月迷糊
(10)、password="true"     设置该文本框是一个密码框(以点代替字符)
EditText:属性
(1)、hint="xxxx"  表示在文本框中显示的数字
(2)、selectAllOnFocus="true"   如果文本框中的内容可选择,设置是否当它获得焦点时自动选中所用的文本
(3)、inputType="xxxx"    xxxx="numberPassword输入密码"   xxxx="number 数值输入框"  xxxx="date 表明是日期输出框" xxxx="phone 电话号码输出框"


2、单选按钮(RadioButton)与复选框(CheckBox)
1、单选按钮
<RadioGroup
android:id="@+id/rg"
android:orientation="horizontal"
android:layout_gravity="center_horizontal">
<RadioButton
android:layout_width="Wrap_content"
android:layout_height="wrap_content"
android:id="@+id/male"
android:text="男"
android:checked="true"      //指定初始是选中这一个按钮
></RadioButton>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/female"
android:text="女"
></RadioButton>
</RadioGroup>
2、复选框
<LinearLayout
android:layout_gravity="center_horizontal"
android:orientation="vertical"
android:layou_width="wrap_content"
android:layout_height="wrap_content"
>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="红色"
android:check="true"
></CheckBox>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="绿色"
></CheckBox>
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="蓝色"
></CheckBox>
</LinearLayout>
3、状态开关按钮(ToggleButton)与开关(Switch)的功能与用法
状态开关按钮和开关的是由Button派生出来的,因此他们的本质还是按钮,支持Button的各种属性、方法也适用于ToggleButton和
Switch。
首先:ToggleButton属性:
checked="true"  设置改按钮是否被选中
textOff 设置当该按钮的状态处于关闭的时显示的文本
textOn  设置当该按钮的状态处于打开的时显示的文本

Switch属性:
checked="true"  设置该按钮是否被选择
switchMinWidth   设置该开关的最小宽度
switchPadding   设置开关与标题文本之间的空白
switchTextAppearance    设置该开关图标上的文本样本
textOff   设置当该按钮的状态处于关闭的时候显示的文本
textOn    设置当该按钮的状态处于打开的时候显示的文本
textStyle  设置该开关的文本风格
thumb     指定使用自定义Drawable绘制该开关的开关按钮
track     指定使用自定义Drawable绘制该开关的开关轨道
typeface   设置该开关的文本的字体风格

猜你喜欢

转载自1163168856.iteye.com/blog/2208069