views:

44

answers:

1

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.

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.

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>

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

A: 

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.

Konstantin Burov
that's what I was afraid of. Thanks for the info.
Kyle