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

用ImageView模拟ImageButton

时间:2015-05-22 13:16:16      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:

ImageButton 显示的图片有白框,用ImageView同样可以实现ImageButton的功能.

1.准备两张imageButton的图片,一张是正常显示,一张是被按下里的显示.

2.自定义下drawable选择器,代码如下 ;

selector_img_view_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:drawable="@color/action_item_pressed_color" android:state_pressed="true"/>
    <item android:drawable="@drawable/actionbar_add_icon" android:state_enabled="true"/>
</selector>

3.将imageView的图片指定为selector_img_view_bg

4.imgeView 的setOnClickListener事件

用ImageView模拟ImageButton

标签:

原文地址:http://www.cnblogs.com/cocl/p/4521827.html

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