在Android上:如何定义适当的动画以最大化一个视图,同时最小化另外两个?

我创建了一个包含3个自定义组件的活动(在xml中定义). 2个组件扩展View,1扩展SurfaceView.它们都位于LinearLayout中,在组件之间平均分配屏幕空间.
Click to see. I’m new so I can’t post images directly…

现在我想在点击它时使用一个View(使用滑动动画)最大化.另外两个应该滑到底部.所有应该同时运行,并且当期望的视图最大化时动画需要保持.

我创建了两个动画(res / anim):shrink_view.xml和max_view.xml

  <?xml version="1.0" encoding="utf-8"?>
    <set xmlns:android="http://schemas.android.com/apk/res/android"     android:interpolator="@android:anim/accelerate_interpolator">
        <translate android:fromYDelta="0" android:toYDelta="100%p" android:duration="4000" />
        <scale 
            android:fromXScale="1" android:toXScale="1" android:fromYScale="1"
            android:toYScale="0.0" android:pivotX="0%" android:pivotY="50%"
            android:fillAfter="false"
            android:startOffset="0" android:duration="4000" android:fillBefore="true" />
    </set>



<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:anim/accelerate_interpolator">
    <translate android:fromYDelta="0" android:toYDelta="100%p" android:duration="4000" />
        <scale 
            android:fromXScale="1" android:toXScale="1" android:fromYScale="1"
            android:toYScale="100" android:pivotX="100%" android:pivotY="100%"
            android:startOffset="0" android:duration="4000" android:fillBefore="true" />
</set>

但这不符合我的要求.我在想我的尝试可能是一个负面因素.那么有人可以提供一些帮助吗?

最佳答案 我没有尝试过你正在做的事,但你可能会发现
this可以帮到你.这是一个关于如何在按下按钮时更改视图动画的教程.它使用ViewFlipper小部件在ViewGroups之间进行更改(例如,包含TextViews,Buttons等的LinearLayouts或RelativeLayouts),使用一些内置动画.这与你的情况有点不同,因为他用他的动画改变整个屏幕,但它可能会让你走上正确的轨道.

点赞