Onlclick 监听器工作不正常..? [英] Onlclick listener is not working properly..?

查看:22
本文介绍了Onlclick 监听器工作不正常..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个按钮,我使用旋转动画将其旋转了 45 度,并应用在点击侦听器上,以烘烤消息.

I have button, which i rotated 45 degrees using rotate animation and applied on click listener that toasting a message.

当我点击上面 50% 的按钮时,吐司正在显示.但是当我点击按钮的下 50% 时,什么都没有显示.

When i click on upper 50% of the button toast is displaying. But when i click on lower 50% of the button nothing is displying.

这里是动画代码.

<?xml version="1.0" encoding="utf-8"?>
<rotate
 xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="45"
    android:toDegrees="45"
    android:pivotX="50%"
    android:pivotY="50%"
    android:duration="0" android:fillAfter="true">
</rotate>

提前谢谢......!

Thanks in advance.....!

推荐答案

我很确定这是 Android 中动画的限制.他们通过实施新的动画系统在 3.0 及更高版本中对其进行了修复.

I'm pretty sure this is a limitation of animation in Android. They fixed it in 3.0 onwards by implementing a new animation system.

在这里阅读:http://android-developers.blogspot.com/2011/02/animation-in-honeycomb.html

最后,之前的动画改变了目标对象的视觉外观......但它们实际上并没有改变对象本身.你可能遇到了这个问题.假设你想从一侧移动一个按钮屏幕的另一侧.您可以使用 TranslateAnimation 来做到这一点,按钮会愉快地滑到屏幕的另一侧.当动画完成后,它会很高兴地回到原来的位置.所以你在 Animation 上找到 setFillAfter(true) 方法,然后再试一次.这次按钮停留在它被设置动画的位置.您可以通过单击它来验证 - 嘿!按钮怎么会出现'不点击?问题是动画改变了按钮的绘制位置,而不是按钮物理存在于容器中的位置.如果你想点击按钮,你必须点击它曾经存在的位置或者,作为一种更有效的解决方案(而且更有用一点给您的用户),您必须编写代码以在动画结束时实际更改按钮在布局中的位置.

"Finally, the previous animations changed the visual appearance of the target objects... but they didn't actually change the objects themselves. You may have run into this problem. Let's say you want to move a Button from one side of the screen to the other. You can use a TranslateAnimation to do so, and the button will happily glide along to the other side of the screen. And when the animation is done, it will gladly snap back into its original location. So you find the setFillAfter(true) method on Animation and try it again. This time the button stays in place at the location to which it was animated. And you can verify that by clicking on it - Hey! How come the button isn't clicking? The problem is that the animation changes where the button is drawn, but not where the button physically exists within the container. If you want to click on the button, you'll have to click the location that it used to live in. Or, as a more effective solution (and one just a tad more useful to your users), you'll have to write your code to actually change the location of the button in the layout when the animation finishes.

正是出于这些原因,我们决定在 Honeycomb 中提供一种新的动画系统,该系统基于属性动画"的理念.

It is for these reasons, among others, that we decided to offer a new animation system in Honeycomb, one built on the idea of "property animation."

这篇关于Onlclick 监听器工作不正常..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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