ImageView切换两种状态下的模式
2016-02-25 21:45
274 查看
1、xml对ImageView的src要设置成selector
drawable/selector.xml
切换图片
Done
<ImageView android:id="@+id/like_icon" android:layout_width="@dimen/will_like_icon_width" android:layout_height="@dimen/will_like_icon_height" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:layout_marginLeft="10dp" android:src="@drawable/selector" />
drawable/selector.xml
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/clickgreat" android:state_pressed="true"/> <item android:drawable="@drawable/clickgreat" android:state_selected="true"/> <item android:drawable="@drawable/great"/> </selector>
切换图片
//深色 likeIcon.setSelected(true); //浅色 likeIcon.setSelected(false);
Done
相关文章推荐
- wex5的组件简介
- Android SearchView的使用
- python装饰器的学习笔记一
- 七牛---Python_SDK_Demos
- 【解决方法】在xcode中修改整个项目名
- hive CLI启动时报错:
- 查找類別所在包的方式
- c++11中的日期和时间库
- iOS 获取对象的全部属性、把model的所有属性和对应的值转化为字典
- (二)Statistical Inference Course Notes
- POJ3280
- HDU 2717 Catch That Cow 水题BFS
- python装饰器的学习笔记二
- iOS之HTTP网络编程
- Openfire集群部署不完全手册
- 【三层架构】之三层扩展七层
- 如何使用eclipse进行嵌入式Linux的开发
- quick cocos 的scheduler 定时器
- PowerPC750(604家族)cache相关HID0寄存器
- 事件的由来