小编Fel*_*lix的帖子

从Android布局转换中排除某些元素的动画

我有一个关于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>
Run Code Online (Sandbox Code Playgroud)

现在我想达到什么样的是,当changingView1changingView2改变他们的能见度movingView或幻灯片上下.

通过为父布局启用LayoutTransition.CHANGING,滑动部件可以正常工作.但这有副作用,当添加或删除项目时,movingView也会被动画化,因为此布局会更改其边界.这就是我的问题,因为这会产生一个非常奇怪的动画.

所以回到我的问题.有没有办法保持滑动动画而不在movingView上动画布局绑定更改?

在禁用layoutTransitions movingView显然没有帮助,因为这只是影响孩子的意见动画.我也试过在父布局上启用和禁用不同的LayoutTransitions但到目前为止没有达到预期的效果.

如果我可以添加更多详细信息,请让我知道,否则我希望有人可以帮助我.

提前致谢!

android android-animation layouttransition

8
推荐指数
1
解决办法
988
查看次数