码迷,mamicode.com
首页 > 其他好文 > 详细

imagebutton 设置点击和按压效果

时间:2015-09-15 13:05:13      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:

 

实现 点击 时 有按压效果 更换颜色

 

 

<ImageButton
android:id="@+id/mediacontroller_Fullscreen_or_not"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:contentDescription="@string/mediacontroller_Fullscreen_or_not"
android:background="@drawable/mediacontroller_fullscreen_selector"
android:src="@drawable/mediacontroller_fullscreen" />

 

 

mediacontroller_fullscreen_selector.xml

 

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

<item android:drawable="@color/mediacontroller_bg_pressed" android:state_focused="true"/>
<item android:drawable="@color/mediacontroller_bg_pressed" android:state_pressed="true"/>
<item android:drawable="@color/transparent" android:state_enabled="false"/>
<item android:drawable="@color/transparent"/>


</selector>

 

colors.xml

<?xml version="1.0" encoding="UTF-8"?>
<resources>

<color name="transparent">#00000000</color>
<color name="mediacontroller_bg_pressed">#ff53c1bd</color>
<color name="mediacontroller_bg">#99000000</color>

</resources>

imagebutton 设置点击和按压效果

标签:

原文地址:http://www.cnblogs.com/qianyukun/p/4809851.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!