I want to put an animation when i am taping the tab i want image rotation animation on tab icon. Below is the Example but it is in iOS.
Asked
Active
Viewed 5,720 times
7

Aditya Vyas-Lakhan
- 13,409
- 16
- 61
- 96

Gaurav Singhal
- 189
- 1
- 12
-
4SO people won't write code for you. but Somebody gave +1 for your link. :) – Mani Jun 28 '16 at 06:45
2 Answers
1
The following approach might work: Create an AnimatedVectorDrawable
as illustrated here https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html and set it as your tab's icon.
Assign a listener to your TabLayout, in TabLayout.OnTabSelectedListener#onTabSelected(TabLayout.Tab tab)
you have access to the tab's icon using tab.getIcon()
. Run the animation associated with your AnimatedVectorDrawable
like so:
final Drawable icon = tab.getIcon();
((Animatable) icon).start();

splatte
- 2,048
- 1
- 15
- 18
-
-
-
Create AnimatedVectorDrawable and onTabSelected get the icon of particular tab and call ((Animatable) icon).start(); to start particular animation, refer developer link given above. – Gaurav Singhal Sep 24 '18 at 09:46
1
I think this is completely based on animation,I suggest you to follow this demo,this is exactly what you looking for.
<com.like.LikeButton
app:icon_type="star"
app:circle_start_color="@color/colorPrimary"
app:like_drawable="@drawable/thumb_on"
app:unlike_drawable="@drawable/thumb_off"
app:dots_primary_color="@color/colorAccent"
app:dots_secondary_color="@color/colorPrimary"
app:circle_end_color="@color/colorAccent"
app:icon_size="25dp"
app:liked="true"
app:anim_scale_factor="2"
app:is_enabled="false"
/>
OUTPUT :

Pratik Butani
- 60,504
- 58
- 273
- 437

Aditya Vyas-Lakhan
- 13,409
- 16
- 61
- 96