I've got a layout like that
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:id="@+id/relativeLayout">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/category_1_full"
android:scaleType="centerCrop"
android:id="@+id/categoryImageView" />
(...)
</RelativeLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_below="@+id/relativeLayout"
>
<GridView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/gridView"
android:numColumns="2"
android:verticalSpacing="10dp"
android:horizontalSpacing="10dp"
/>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
and then I do animate the first relative layout like that
float _height = 120.05f;
ObjectAnimator a1 = ObjectAnimator.ofFloat(relativeLayout, "translationY", -_height);
ObjectAnimator a2 = ObjectAnimator.ofFloat(swipeRefreshLayout, "translationY", -_height);
a2.addUpdateListener(new ValueAnimator.AnimatorUpdateListener()
{
@Override
public void onAnimationUpdate(ValueAnimator animation)
{
swipeRefreshLayout.invalidate();
gridView.invalidate();
}
});
AnimatorSet animation = new AnimatorSet();
animation.play(a1).with(a2);
animation.start();
As you can see I tried to invalidate concerned views into an updateListener but it doesn't work.
I thought the refresh/gridViews will update automatically because of the relation on the layout (match_parent and alignXX) but it is not the case. How should I do?