android-Color State List Resource
2015-12-03 14:35
246 查看
> A
an object you can define in XML that you can apply as a color, but will actually change colors, depending on the state of the
to which it is applied. For example, a
can exist in one of several different states (pressed, focused, or neither) and, using a color state list, you can provide a different color during each state.
> XML file saved at
This layout XML will apply the color list to a View:
ColorStateListis
an object you can define in XML that you can apply as a color, but will actually change colors, depending on the state of the
Viewobject
to which it is applied. For example, a
Buttonwidget
can exist in one of several different states (pressed, focused, or neither) and, using a color state list, you can provide a different color during each state.
> XML file saved at
res/color/button_text.xml:
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:color="#ffff0000"/> <!-- pressed --> <item android:state_focused="true" android:color="#ff0000ff"/> <!-- focused --> <item android:color="#ff000000"/> <!-- default --> </selector>
This layout XML will apply the color list to a View:
<Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/button_text" android:textColor="@color/button_text" />
相关文章推荐
- 新浪微博Android SDK Java代码规范
- Android动画笔记
- 【资源汇总】Android应用解决方案全攻略
- 【风马一族_Android】代码英语之二 布局文件的Android各个参数
- Android动画学习笔记-Android Animation
- MTK Android software Tools工具的说明
- 安卓JNI--Android studio 1.5 JNI开发初探
- Android 笔记
- Android将Activity打成jar包供第三方调用(解决资源文件不能打包的问题)
- Android SQLite数据库相关知识
- android 高斯模糊实现
- android 高斯模糊实现
- android 高斯模糊实现
- Android 获取无线蓝牙MAC信息代码
- imx6 android 5.0 权限修改
- Android中JNI编程详解
- Android异步消息框架
- 【转载】Android样式的开发:selector篇
- 在安装Android Studio之后,启动时报错:Argument for @NotNull parameter 'name' of com/android/tools/idea/
- android控件获取屏幕坐标