1、TextView:(文本框):不能编辑
android:textColor="@color/tv_show_color" 字体颜色
android:textSize="@dimen/tv_show_size" 字体大小
android:typeface="monospace" 字体类型
android:textScaleX="10" 字体间的间隔
android:textStyle="bold|italic" 字体样式
常用的事件OnClickListener
2、EditText(编辑框)
3、Button、ImageButton(区别?Button可以放背景和文字,ImageButton只能放背景图片)
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:andro/>
</selector>
背景选择器作用:根据事件源不同的状态去选择满足条件的图片或颜色
4、RadioGroup、RadioButton
用到的事件:实现RadioGroup.OnCheckedChangeListener()接口 注意区别复选框的事件
5、CheckBox
实现的CompoundButton.OnCheckedChangeListener接口
6、ImageView(图片框)
android:scaleType="fitCenter" 图片显示比例类型
android:adjustViewBounds="true" 图片根据imageView的大小自动调整
android:src="@drawable/bomb5" 存放的图片
7、资源文件中 style标签的使用
作用:把重复的属性抽取出来被称为一个样式,样式可以继承重写,可以减少代码的冗余
调用: style="@style/ed_style"
注意:继承方式有两种,如下:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="ed_style">
<item name="android:textColor">@color/ed_color</item>
<item name="android:textSize">@dimen/ed_dimen</item>
<item name="android:inputType">textPassword</item>
</style>
<style name="ed2_style" parent="@style/ed_style">
<item name="android:textColor">@color/ed_color2</item>
</style>
<style name="ed_style.ed3_style" >
<item name="android:textColor">@color/ed_color2</item>
</style>
</resources>
8、修改控件的外观可以在drawable新建 shape标签样式
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:andro/>
</shape>
9、onKeyDown事件(键盘事件)
只要重写Activity的onKeyDown事件
10、onTouchEvent事件(触摸事件)
只要重写Activity的onTouchEvent事件