Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animated Vector Drawable for on click rotation of arrow

I need to have an expandable recycler view. I am planning to use an animated vector drawable for the collapse and expand arrow animation.

There is this setExpandCollapseListener using which I can start the rotation. How to use Animated Vector Drawable to get the same effect as shown below?

Vector drawable for expand button:

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="306"
android:viewportHeight="306"
android:width="306dp"
android:height="306dp">
<path
    android:pathData="M153 247.35L306 94.35 270.3 58.65 153 175.95 35.7 58.65 0 94.35Z"
    android:fillColor="#000000" />
</vector>

Vector drawable for collapse button:

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:viewportWidth="306"
android:viewportHeight="306"
android:width="306dp"
android:height="306dp">
<path
    android:pathData="M270.3 247.35L306 211.65 153 58.65 0 211.65 35.7 247.35 153 130.05Z"
    android:fillColor="#000000" />
</vector>

enter image description here

like image 933
suku Avatar asked Nov 05 '16 00:11

suku


1 Answers

All you need is just one line of code -

view.animate().rotationBy(degree_of_rotation).setDuration(duration_in_milliseconds).start();
like image 108
Akshay Sahai Avatar answered Oct 13 '22 22:10

Akshay Sahai