私はいくつかをテストするためにこのレイアウトを持っていますAnimations
。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/frame1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#00ff00"
android:orientation="vertical">
<TextView
android:id="@+id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1"/>
<TextView
android:id="@+id/text2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="2"/>
</LinearLayout>
<LinearLayout
android:id="@+id/frame2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#0000ff">
<ListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/edit_style"/>
</LinearLayout>
</LinearLayout>
私が達成したいのは、LinearLayout の ListViewlist
がframe2
画面の上部まで成長し、LinearLayoutframe1
が縮小することです。
ObjectAnimator
これは、次のAnimatorSet
ように と を使用して非常に簡単に実行できます。
ObjectAnimator animframe1 = ObjectAnimator.ofInt(frame1, "bottom", 0);
ObjectAnimator animframe2 = ObjectAnimator.ofInt(frame2, "top", 0);
ObjectAnimator listview = ObjectAnimator.ofInt(list, "bottom", frame2.getBottom());
AnimatorSet set = new AnimatorSet();
set.setDuration(1000L);
set.playTogether(animframe1, animframe2, listview);
set.start();
私がしていることは、ビューtop
の とbottom
プロパティを操作して、拡大/縮小効果を持たせることです。
それは私が望むように動作しますが、1 つの欠点があります: ListView が成長している間、(そこにある) 追加の項目は表示されません。部屋はそこにあるはずですが、アニメーションの後に ListView をクリックした場合にのみ、追加の項目が表示されます。
アニメーションの実行中に追加のアイテムをリロードする必要があることを ListView に伝えるにはどうすればよいですか?
電話をかけようとしlist.invalidate()
ましたAnimationUpdateListener
が、成功しませんでした。私が呼び出すlist.requestLayout()
と、アニメーションはありません。