1、TextView:文本显示控件
---------------------------------------
特征:
用于显示字符串的控件
属性:
1. android:text -> 控件上显示的文本,取值可以使字符串,或者@string/???
2. android:gravity -> 文本在控件内部的对齐方式,取值参考android:layout_gravity属性
3. android:textSize -> 文本尺寸,取值为以sp为单位的数值,例如14sp,数值建议不小于10,也可以取值为@dimen/???
4. android:textColor -> 文本颜色,取值为RGB颜色值,或者@color/???
5. android:singleLine -> 单行显示,即当文字在控件内1行显示不下时,应该如何处理,取值为true或者false,取值为true时,将不显示超出的部分,取值为false时,将在控件可用范围内继续显示。
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView" />


2、EditText:文本输入框控件

---------------------------------------
特征:
可以使用该控件输入字符
EditText是TextView的子类
属性:
1. android:inputType -> 输入的字符类型,取值为枚举类型,例如text、textPassword、number、phone
2. android:hint -> 提示文字,当该控件内没有输入任何内容时的提示问题,取值参考android:text属性
3. android:textColorHint -> 提示文字的颜色,取值参考android:textColor属性
Ps:
1. 如果某个EditText控件存在子级节点<requestFocus />则表示该EditText默认获取到焦点,即光标定位在该EditText控件上


3、ImageView:图片显示控件

----------------------------------
ImageView是用于显示图片的控件
属性:
android:src -> 需要显示的图片的来源,取值通常为 @drawable/???
android:contentDescription -> 使用文字对图片进行描述,如果不想设置,可以取值为 @null
android:scaleType -> 图片的缩放模式,当图片的尺寸与ImageView的尺寸不符时有效,取值为枚举类型fitXY xy适应
android:adjustViewBounds 是否保持宽高比。需要与maxWidth、MaxHeight一起使用,否则单独使用没有效果。
android:cropToPadding 是否截取指定区域用空白代替。单独设置无效果,需要与scrollY一起使用,效果如下,实现代码见代码部分:
android:maxHeight 设置View的最大高度,单独使用无效,需要与setAdjustViewBounds一起使用。如果想设置图片固定大小,又想保持图片宽高比,需要如下设置:
1) 设置setAdjustViewBounds为true;
2) 设置maxWidth、MaxHeight;
3) 设置设置layout_width和layout_height为wrap_content。
android:maxWidth 设置View的最大宽度。同上。
android:scaleType 设置图片的填充方式。
android:tint 将图片渲染成指定的颜色。见下图: 左边为原图,右边为设置后的效果,见后面代码
网络上下载下来的图片自适应: android:adjustViewBounds="true"

<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />


4、Buttons (按钮)

----------------------------------

1)Button
特征:
用于用户点击的按钮
Button是TextView的子类
属性:
(无)
Ps:
1. Button控件默认存在android:minWidth和android:minHeight属性
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />

2)ImageButton

图片按钮

<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />//图片资源:小机器人

3)Switch

开关按钮

<Switch
android:id="@+id/switch1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Switch" />

4)RadioButton (单选按钮,结合RadioGroup使用)
RadioButton用于在一组选项中能够选取有且仅有其中1项。
RadioButton是CompoundButton的子类,也是TextView的间接子类。
RadioGroup是RadioButton的容器,是LinearLayout的子类。
只有同一个RadioGroup的若干个子级RadioButton才是互斥的。
每一个RadioButton不可以通过反复点击取消选中,只能通过选中其它的互斥项才可以取消选中。
属性:

android:checked -> 默认是否勾选,取值为true/false


<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

android:text="RadioButton" />


5)CheckBox(多选按钮)
CheckBox是可以在一组CheckBox勾选其中的若干项的控件。
CheckBox是TextView的间接子类。
属性:
android:checked -> 默认是否勾选,取值为true/false
监听器:

CompoundButton.OnCheckedChangedListener


<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CheckBox" />

更多相关文章

  1. android解决无法设定listview的item高度(设置行高)
  2. Android(安卓)EditText禁止输入Emoji后设置android:maxLength失
  3. android zxing 解析二维码图片与生成二维码图片
  4. android 透明度
  5. Android(安卓)控件阴影实现
  6. Android(安卓)对话框【Dialog】去除白色边框代码
  7. Android(安卓)上传图片到服务器(多文件上传)
  8. android 权限介绍(一)
  9. android Toolbar的使用结合状态栏与返回键

随机推荐

  1. Win7+Eclipse下Android开发环境配置
  2. android官方下载链接最新版 (Windows版本
  3. Android(安卓)Intent机制实例详解(Activi
  4. 【Android】窗口机制分析与UI管理系统
  5. Android(安卓)性能优化案例
  6. Android环境配置
  7. 初窥 Android(安卓)模拟器 2.0,这些年来最
  8. Android主题与Toolbar样式之间的关系
  9. android 发送短信的两种方式,以及接收报告
  10. Android(安卓)安全卫士 第二天_注意事项