Android样式和主题之选择器的实例讲解
更新时间:2019年03月30日 10:04:05 作者:徐刘根
今天小编就为大家分享一篇关于Android样式和主题之选择器的实例讲解,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧
Android学习笔记之样式和主题之选择器
(1)布局文件
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:layout_marginBottom="189dp" android:layout_marginLeft="55dp" android:textColor="@color/button_selector" android:text="测试颜色列表状态" /> </RelativeLayout>
需要在按钮里边使用:android:textColor="@color/button_selector"
(2)需要在res目录下创建一个color文件夹
button-selector文件内容如下:
<?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"/> <item android:state_focused="true" android:color="#ff0000ff"/> <item android:color="#ff000000"/> </selector>
其他文件不做修改,默认的就可以
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对脚本之家的支持。如果你想了解更多相关内容请查看下面相关链接
相关文章
解析Android中实现滑动翻页之ViewFlipper的使用详解
有一些场景,我们需要向用户展示一系列的页面。比如我们正在开发一个看漫画的应用,可能就需要向用户展示一张一张的漫画图片,用户使用手指滑动屏幕,可以在前一幅漫画和后一幅漫画之间切换。这个时候ViewFlipper就是一个很好的选择2013-05-05Android Intent传递对象的两种方法(Serializable,Parcelable)详细介绍
这篇文章主要介绍了Android Intent传递对象的两种方法(Serializable,Parcelable)详细介绍的相关资料,需要的朋友可以参考下2016-12-12
最新评论