android imageview onClick动画 [英] android imageview onClick animation

查看:15
本文介绍了android imageview onClick动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这是一个奇怪的问题,但我尝试在 ImageView 上设置 onClicklistener 并且它有效.但问题是用户无法感知点击.我的意思是,如果你们中的一些人在其他移动环境(如 Apple iPhone)上工作过,那么当我们在其他环境中单击图像时,它会对图像产生影响,以便用户可以理解图像已被单击.

I guess this is kind of an odd question but I have tried setting onClicklistener on an ImageView and it has worked. But the problem is that the user cannot sense the click. I mean if some of u have worked on other mobile environs(like Apple iPhone) then when we click on an Image in other environs then it gives an effect on the image so that the user can understand that the image has been clicked.

我曾尝试使用 setalpha 方法设置 alpha,但它不起作用.虽然同样的事情在 onFocusListener 实现上运行良好.some1 可以建议一种不同的方式来修改点击图片...

I have tried setting alpha using setalpha method but it doesn't work. Though the same thing is working fine on onFocusListener implementation. Can some1 suggest a different way to modify the image on click...

我是 android 新手,所以还没有了解简单动画的细微差别......如果有任何简单的动画我可以使用,请告诉我.

I am new to android so haven't learnt the nuances of simple animation also... if there is any simple animation I can use for the same then please let me know.

谢谢!

推荐答案

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

<alpha
android:fromAlpha = "1.0"
android:toAlpha = "0.5"
android:duration = "300">
</alpha>
<scale
android:fromXScale = "1"
android:toXScale = "0.9" 
android:fromYScale = "1"
android:toYScale = "0.9" 
android:pivotX="50%"
android:pivotY="50%" 
android:duration = "50">
</scale>
</set>

我不知道这是否是正确的方法,但如上所述定义动画就可以了.现在我们只需要给予

I don't know if this is the correct method but defining an animation as mentioned did the trick. Now we just have to give

public void onClick(View v) {
v.startAnimation(AnimationUtils.loadAnimation(Context, R.anim.image_click));
//Your other coding if present
}

在 OnClick 方法中,更改将可见...

in the OnClick method and the change will be visible...

这篇关于android imageview onClick动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆