首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

关于animation结束时,View OnClick触发位置的有关问题

2013-06-19 
关于animation结束时,View OnClick触发位置的问题我写了一个简单的动画:?xml version1.0 encodingut

关于animation结束时,View OnClick触发位置的问题
我写了一个简单的动画:


<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
 android:fillAfter="true">
<translate android:fromXDelta="0" android:toXDelta="-320"
   android:fromYDelta="0" android:toYDelta="0"
   android:duration="5000"/>
</set>

在antivity里的button使用了这个动画后,由于android:fillAfter="true",故动画结束时button停在了动画最后一祯的位置,但是发现button的onClick还是在动画第一祯的位置,也就是最初的位置可以触发onClick。
而我原来的解决办法是,将android:fillAfter="false",然后在动画结束时button.layout(l,t,r,b)来设置位置,但是这样View会闪一下,效果很不好,大家有什么好的方法吗?谢谢!

[解决办法]
试下这个效果, 之前view会闪一下我也是被郁闷了很久...

TranslateAnimation animationOpen =new TranslateAnimation(
Animation.RELATIVE_TO_SELF, -1.0f,
Animation.RELATIVE_TO_SELF, 0.0f, 
Animation.RELATIVE_TO_SELF, 0.0f, 
Animation.RELATIVE_TO_SELF, 0.0f);
animationOpen.setDuration(500);

[解决办法]
动画开始的时候你把button的visiable设置为gone, 然后设置layout位置, 在设置visiable,同时在这里开启上面的动画。。。
[解决办法]
引用:
动画开始的时候你把button的visiable设置为gone, 然后设置layout位置, 在设置visiable,同时在这里开启上面的动画。。。

好办法帮顶了

热点排行