Skip to content Skip to sidebar Skip to footer

Center Vector With Animation

I have vector which I'm trying to scale into bigger after click on it, but its position is always in the top left corner of viewport area but I want to have it in the center, and a

Solution 1:

You need to use the viewport height and width, not the android:heightand width.

<vector xmlns:android="http://schemas.android.com/apk/res/android"
  android:height="24dp"
  android:viewportHeight="81.875"
  android:viewportWidth="32.795"
  android:width="24dp">

  <!--  <group name="dot_name"
      pivotX="viewportHeight / 2"
      pivotY="viewportWidth / 2">  Calculate the values by yourself, write the calucalted values in there. This moves the reference point to the middle -->

  <group name="dot_name"
         pivotX="40.9375"
         pivotY="viewportWidth / 2">

    <path
        android:fillColor="#FF000000"
        android:pathData="M-0.01,32.82a32.81,32.81 0,1 1,65.61 0c0,28.94 -32.8,49.04 -32.8,49.04S-0.01,61.77 -0.01,32.82Z" />

  </group>

</vector>

Post a Comment for "Center Vector With Animation"