Android之层次statelist属性
来源:互联网 发布:海尔智能软件下载 编辑:程序博客网 时间:2024/06/06 12:27
在菜单按钮中可以使用点击按钮变化状态的效果
创建Android_StyleAndStatelist下的res中新建drawable,然后在drawable中新建button.xml,添加tab_a.png
tab_b.png
tab_c.png三张图片
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/tab_a" android:state_pressed="true"></item> <item android:drawable="@drawable/tab_c" android:state_focused="true"></item> <item android:drawable="@drawable/tab_b"></item></selector>
在activity_main.xml中
<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="com.example.android_styleandstatelist.MainActivity" > <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" android:layout_marginLeft="130dp" android:layout_marginTop="146dp" android:background="@drawable/button" /> </RelativeLayout>
运行效果:点击button按钮发生变化,由一张图片变化到另一张图片
0 0
- Android之层次statelist属性
- Android之层次layer-list属性
- StateList Drawable的用法以及各属性的作用
- StateList资源
- Android开发之屏幕元素层次结构
- Android开发之屏幕元素层次结构
- StateList Drawable文件
- android层次
- Android之xml属性
- android之TextView属性
- android之drawable属性
- Android之布局属性
- Android之布局属性
- Android属性之excludeFromRecents
- android之属性动画
- Android之布局属性
- android之属性动画
- Android之布局属性
- Spark LDA 主题预测
- Arduino - RGB全彩LED模块
- mtk M8735平台android L版本修改记录
- [POJ]1844 Sum
- 手把手教你使用Git
- Android之层次statelist属性
- 236. Lowest Common Ancestor of a Binary Tree
- iOS提交后申请加急审核
- 开源项目之Android Afinal框架
- 从apache mod_php到php-fpm
- android studio 使用问题2
- 单链表代码3
- textview设置不同格式字体颜色
- Imageview另类切换图片的思路