i have 2 views in a RelativeLayout like this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android";
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <View
        android:id="@+id/view1"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:background="@drawable/shape_red"/>

    <View
        android:id="@+id/view2"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_below="@id/view1"
        android:background="@drawable/shape_blue"/>

</RelativeLayout>

now, i animate the y property of view1 from 0 to 300. but i want view2 to 
change its position according to view1 - because view2 is set to be below 
(layout-below) view1.

as this isn't working, i tried to add an onAnimationEnd listener to the 
animation. like this:

    ObjectAnimator ani = ObjectAnimator.ofFloat(view1, "Y", 200);
    ani.setDuration(2000);
    ani.addListener(new AnimatorListenerAdapter()
    {
        @Override
        public void onAnimationEnd(Animator animation)
        {
            LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, 
view2.getHeight());
            params.addRule(RelativeLayout.BELOW, view1.getId());

            view2.setLayoutParams(params);
        }
    });

but view2 didn't change its position at all.

i would like to avoid making a new animation for view2 if possible, so 
please don't bother to suggest one. ;)

does anyone have some suggestions?

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to