今天美工 直接给我一张图片,要我实现图片点击之后有阴影效果,当时想到了ImageButton,随即自己写了个Demo,发现ImageButton继承ImageView 会有一个默认的背景样式,而且在布局中设计src(前景) 太丑,于是自己写了个自定义控件ImageView实现了点击之后,点击区域有一个灰色的阴影效果,如下:
添加监听回调等;
布局文件代码:
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.hanzheng.ima