控件按钮的点击效果
2012-09-11 09:08
148 查看
手机上按钮通常点击时显示一种效果,没有点击时是另一种效果,这也是默认的情况。但是如果你使用图片按钮,并把背景色设成#00000000后,点击后的效果就看不到了,对于用户来说很不友好,所以你需要做一些修改:使用两张图片,一张是正常显示,一张是点击后的效果。这也是为什么打开别人的res文件夹后总会看到相同前缀名的图片资源的原因。
下面说一下怎么实现的:
1.新建一个drawable文件夹,拷贝icon_play_prev_normal.png和icon_play_prev_pressed.png两张图片进去。
2.还在上面的文件夹中编写icon_play_prev.xml该文件
3.在layout文件夹中编写需要的布局文件
下面说一下怎么实现的:
1.新建一个drawable文件夹,拷贝icon_play_prev_normal.png和icon_play_prev_pressed.png两张图片进去。
2.还在上面的文件夹中编写icon_play_prev.xml该文件
<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:drawable="@drawable/icon_play_prev_pressed" android:state_pressed="true"/> <item android:drawable="@drawable/icon_play_prev_normal"/> </selector>
3.在layout文件夹中编写需要的布局文件
<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:background="@drawable/background" > <ImageButton android:background="#00000000" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon_play_prev" /> </RelativeLayout>
相关文章推荐
- 自定义UIButton--iPhone按钮控件点击效果写法
- 自定义UIButton--iPhone按钮控件点击效果写法
- 第2章 ConfirmButton按钮点击确认控件
- Android仿饿了么加入购物车旋转控件自带闪转腾挪动画的按钮效果(实例详解)
- 按钮点击效果
- Android进阶——自定义View之继承系统控件实现自带删除按钮动画效果和软键盘自动悬浮于文本框下方
- 写一个方法进行各种属性的更新,而不要每个界面设置改变都改变一个属性。就是点击应用或确定按钮时调用这个更新属性的方法,遍历所有(控制对象属性的)界面控件的状态(值),进行属性修改和刷新。
- 图片轮换效果实现代码(点击按钮停止执行)
- Repeater控件中点击按钮后获取某一行的数据
- 图片轮换效果(点击按钮停止执行)
- 点击按钮,生成一组一组combobox和slider时,避免控件Id相同,导致控件冲突的方法
- AngularJS实现按钮提示与点击变色效果
- listview中有按钮、图片等需要不同点击处理的控件如何处理
- HTML不同按钮的点击效果不同(创)
- Java实现按钮隐藏点击动态效果的另类方法
- html-手机端-点击按钮-去高亮-加点击效果
- android按钮被点击文字颜色变化效果
- repositoryItemButtonEdit1控件的按钮点击
- 回车直接实现点击某按钮的效果
- android 按钮点击效果实现 在studio下出现的错误