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>
All you need is just one line of code -
view.animate().rotationBy(degree_of_rotation).setDuration(duration_in_milliseconds).start();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With