anroid 点击图形缩小
2015-08-19 08:30
183 查看
这个功能是由selector + shape xml文件实现的 主要原理是把stroke的width变大把图形挤压变小,我用的是textview做测试,不知道其它控件是否生效,在此声明,以防参考者误用,也许还有更简单的方法,但我这里只是提供一种可以实现的方法,不喜勿喷,觉得有用的请赞。
首先你的写一个点击时候要显示的样子
定义为 suoxiao.xml
在者你要设置没有点击时的显示
shape.xml
最关键的一步就是selector.xml
设置background为selector就可以了
首先你的写一个点击时候要显示的样子
定义为 suoxiao.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > //颜色为你的背景颜色 <stroke android:width="4dp" android:color="#326475" /> 颜色为控件原有颜色 <solid android:color="#ff202a"/> </shape>
在者你要设置没有点击时的显示
shape.xml
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="#ff202a" /> </shape>
最关键的一步就是selector.xml
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_pressed="true" android:drawable="@drawable/application_menu_first_suoxiao"></item> <item android:drawable="@drawable/application_menu_first_shape" android:state_pressed="false"></item> </selector>
设置background为selector就可以了
相关文章推荐
- 必须掌握的排序
- OC: 类的扩展、类的延展、协议、 NSDate
- UITouch触摸与手势
- 3.3内容提供者ContentProvider,供其他软件访问本软件的数据操作
- 子类继承父类(父类和子类里:块、静态块、构造和方法覆写)之间调用顺序
- 单例——iOS学习连载19
- java的队列
- 2015 HUAS Summer Trainning #6~I
- 广佛肇城轨年内通车 佛山西站预计2017年中通车
- 广佛肇城轨年内通车 佛山西站预计2017年中通车
- 消息队列是先进先出
- iOS开发 自定义UICollectionViewLayout实现Masonry Layout
- Spring 的下载、安装和使用
- 高进度乘法FFT优化
- C++:STL标准入门汇总
- 转载:提示行魔术
- POINT结构体
- STL一般总结
- SAP的成本中心与利润中心的关系
- 关于spring @postConstruct失效的问题