无多重效果的触摸/点击效果图像视图(Android)

无多重效果的触摸/点击效果图像视图(Android),android,imageview,Android,Imageview,当按下imageview时,会显示某种效果。我使用imageview作为按钮,所以需要在触摸上显示一些效果。许多现有线程建议使用多个图像的选择器。这是太多的工作,因为我有很多图像视图。我也愿意扩展imageview类。任何想法或解决方法 在单击功能中添加 ImageView img= (ImageView) view.findViewById(R.id.theID); Animation animation = AnimationUtils.loadAnimation(getApplicat

当按下imageview时,会显示某种效果。我使用imageview作为按钮,所以需要在触摸上显示一些效果。许多现有线程建议使用多个图像的选择器。这是太多的工作,因为我有很多图像视图。我也愿意扩展imageview类。任何想法或解决方法

在单击功能中添加

 ImageView img= (ImageView) view.findViewById(R.id.theID);
 Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.alpha);
 img.startAnimation(animation);
在资源中创建一个
anim
文件夹,然后清除名为
alpha

在文件内部粘贴以下内容

<alpha xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/accelerate_interpolator"
    android:duration="50"
    android:fromAlpha="0.5"
    android:toAlpha="1.0" />

你看过
ImageButton
class吗?谢谢大家。Imagebutton不好,因为我在自定义标题栏上使用它@saree,你已经指定了一种方法,我必须为每个imageview使用选择器。我喜欢karan Sugesion。但我在寻找像辉光效果或一些动画。那么,你在自定义标题栏上使用它是什么呢?
public void myClickFunction(View v) {
    ImageView img = (ImageView) v.findViewById(R.id.theID);
     Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.alpha);
     img.startAnimation(animation);   
}