11

Android レイアウト遷移フレームワークについて質問があります。特に、別のビューの可視性に応じて、レイアウトの特定の部分が上下にスライドする効果を実現したいと考えています。

次のレイアウトを想像してください。(そして、ネストされた LinearLayouts を見落としてください ;) )

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:animateLayoutChanges="true">

    <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        <View
                android:id="@+id/changingView1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="gone"/>

        <View
                android:id="@+id/changingView2"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:visibility="gone"/>

    </LinearLayout>

    <LinearLayout
            android:id="@+id/movingView"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:animateLayoutChanges="false"/>

</LinearLayout>

今私が達成したいのは、changeingView1とchangingView2がその可視性を変更すると、 movingViewが上下にスライドすることです。

親レイアウトのLayoutTransition.CHANGINGを有効にすることで、スライド部分が正常に動作するようになります。ただし、これには、このレイアウトが境界を変更するため、追加または削除されたアイテムがある場合に、movingViewもアニメーション化されるという副作用があります。そして、これが非常に奇妙に見えるアニメーションになるため、ここに私の問題があります。

それでは私の質問に戻ります。movingViewでレイアウト バウンドの変更をアニメーション化せずにスライド アニメーションを維持する方法はありますか?

これは子ビューのアニメーションにのみ影響するため、movingView でlayoutTransitionsを無効にしても明らかに役に立ちません。また、親レイアウトでさまざまな LayoutTransitions を有効または無効にして遊んでみましたが、これまでのところ、目的の効果はありませんでした。

詳細を追加できる場合はお知らせください。そうでない場合は、誰かが私を助けてくれることを願っています。

前もって感謝します!

4

2 に答える 2