Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/198.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android-如何在矢量图像上实现中央比例动画_Android_Xml_Animation_Scale_Android Vectordrawable - Fatal编程技术网

Android-如何在矢量图像上实现中央比例动画

Android-如何在矢量图像上实现中央比例动画,android,xml,animation,scale,android-vectordrawable,Android,Xml,Animation,Scale,Android Vectordrawable,我最近开始涉足矢量图像和动画。但是,我希望在路径变形动画完成后,能够在所有方向上均匀缩放图像 我已经尝试在任何我能应用的地方应用pivotX和Y,但似乎没有什么不同 我怎样才能达到一个中心尺度,而不是仅仅从左向右扩展 test_layout.xml 动画_logo.xml 缩放动画 closed_logo.xml 我知道这个问题很老,但只是以防万一,它对任何人都有帮助 将pivotX和pivotY添加到要设置动画的组中。。 所以对于你的情况,改变 <group andro

我最近开始涉足矢量图像和动画。但是,我希望在路径变形动画完成后,能够在所有方向上均匀缩放图像

我已经尝试在任何我能应用的地方应用pivotX和Y,但似乎没有什么不同

我怎样才能达到一个中心尺度,而不是仅仅从左向右扩展

test_layout.xml


动画_logo.xml


缩放动画


closed_logo.xml


我知道这个问题很老,但只是以防万一,它对任何人都有帮助

将pivotX和pivotY添加到要设置动画的组中。。 所以对于你的情况,改变

  <group android:name="logo">



你是如何计算pivotx和pivotYIMHO的值的?这是不正确的,pivotx/Y应该使用viewportWidth/Height值,所以中心应该是~37。实际上,对我有效的是pivotx和pivotY应该是具有android:viewportHeight的视口的1/2,所以对于上面的示例,它应该是75/2
<?xml version="1.0" encoding="utf-8"?>
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/closed_logo" >
    <target
        android:animation="@anim/scale"
        android:name="logo"/>
</animated-vector>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<objectAnimator
    android:duration="1500"
    android:propertyName="scaleX"
    android:valueFrom="1.0"
    android:valueTo="10"
    android:valueType="floatType"/>
<objectAnimator
    android:duration="1500"
    android:propertyName="scaleY"
    android:valueFrom="1.0"
    android:valueTo="10"
    android:valueType="floatType"/>
    <?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:viewportWidth="75"
    android:viewportHeight="75"
    android:width="1000dp"
    android:height="1000dp">
    <group android:name="logo">
        <path
            android:name="box"
            android:fillColor="#DADADA"
            android:pathData="M65.5,54.4L11.1,65.5L0,11.1L54.4,0L65.5,54.4z"/>


    <path
            android:name="bottom_left"
            android:fillColor="#47A89C"
            android:pathData="M 7.1,22.2 l 15.2,36.0 l 10.4,-25.6 L 32.699997,32.6 L 7.1,22.2 L 7.1,22.2z" />

        <path
            android:name="top_left"
            android:fillColor="#564B74"
            android:pathData="M43.1,7.1L7.1,22.2l25.6,10.4L43.1,7.1z" />

        <path
            android:name="top_right"
            android:fillColor="#D2A219"
            android:pathData="M 22.3,58.2 L 58.3,43.0 l 0.0,0.0 L 32.7,32.6 L 22.3,58.2z" />

        <path
            android:name="bottom_right"
            android:fillColor="#BD6474"
            android:pathData="M 32.7,32.6 L 58.3,43.0 l 0.0,0.0 L 43.0,7.1 L 32.7,32.6z" />
    </group>
</vector>
  <group android:name="logo">
  <group android:name="logo" android:pivotX="37.5" android:pivotY="37.5">