Android animation 如何在android中制作两次矩形比例

Android animation 如何在android中制作两次矩形比例,android-animation,Android Animation,我有一个矩形,我知道如何通过xml中的动画进行缩放,如下所示 <?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > <scale android:duration="2000" android:fromXScale="1.0" android:fromYScale="1.0" a

我有一个矩形,我知道如何通过xml中的动画进行缩放,如下所示

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >

<scale
    android:duration="2000"
    android:fromXScale="1.0"
    android:fromYScale="1.0"
    android:pivotX="50%"
    android:pivotY="100%"
    android:toXScale="1.0"
    android:toYScale="5.0" />

</set>

它只允许我把一个矩形放大一次,并且只保持那个比例一次。我希望它在这样的情况下,每次我增长的矩形,我使规模再次扩大到一个更大的大小。我该怎么做?

我不确定我是否理解这个问题。但是,我认为问题在于您在practice函数中声明了视图。这意味着它将每次重新加载,然后进行缩放。我认为您需要在函数外部声明视图(例如在
onCreate()
onCreateView()
)并在需要时调用
practice(test)

public void practice(View view) {
        View test = (View) findViewById(R.id.view1);
        Animation scale = AnimationUtils.loadAnimation(getApplicationContext(),             
        R.anim.scale);
        scale.setFillAfter(true);
        scale.setFillBefore(true);
        test.startAnimation(scale);
     }