点击ImageView的位置变化的动画 - 机器人 [英] clickable imageview location change with animation - android

查看:203
本文介绍了点击ImageView的位置变化的动画 - 机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个随机配备内部RelativeLayout的一个ImageView的。当ImageView的点击,我的动画以动画的翻译在整个RelativeLayout的往下移动。

I have an imageview that's included inside a RelativeLayout. When the imageview is clicked, I animate the entire RelativeLayout with a translate animation to move it down.

当我再次点击ImageView的(在它的新的位置),它应该将它移回了,但事实并非如此。但是,如果我点击ImageView的开始的地方,它确实动了整个面板中的备份。为什么ImageView的不动与RelativeLayout的......至少就它的可点击。实际的图像是移动的,但那个地方是可以点击的不是。

when I click the imageview again (in it's new location) it's supposed to move it back up, but it does not. However, if I click where the imageview started, it does move the entire "panel" back up. Why is the imageview not moving with the relativelayout...at least insofar as the clickability of it. The actual image is moving, but the spot where it's clickable is not.

这是我的xml的布局:

here is my xml for the layout:

<RelativeLayout
    android:layout_alignParentTop="true"
    android:layout_alignParentLeft="true"
    android:layout_width="fill_parent"
    android:layout_height="120px"       
    android:layout_marginTop="-106px"
    android:id="@+id/chatbox"
    android:visibility="invisible">
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="106px"
        android:background="#000000"
        android:id="@+id/chattext" />
    <ImageView
        android:layout_width="20px"
        android:layout_height="14px"
        android:id="@+id/chatbubble"
        android:layout_below="@id/chattext"
        android:src="@drawable/chatbubble" />
</RelativeLayout>

编辑:我要补充一点,我使用Animation.setFillAfter(真)持有面板到位动画完成后,

I should add that I'm using Animation.setFillAfter(true) to hold the panel in place after the animation completes.

推荐答案

这是因为动画其实并不影响观点立场,他们只是吸引他们。因此,在新的地方来处理点击你必须把东西存在(即不可见的FrameLayout)。或者,您可以更改动画的意见利润率完整的,所以实际的意见将移动到的地方。

This is because animations actually do not affect views positions, they just draw them. So to handle click at new place you have to place something there (i.e. invisible FrameLayout). Or you can change your views margins on animation complete, so the views actually will move to the place.

这篇关于点击ImageView的位置变化的动画 - 机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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