How can I put the animation like the one WhatsApp has in its search bar when opening and closing:
This is how I have my current animation :
clase
@Override
public void onSearchViewShown() {
searchView.startAnimation(AnimationUtils.loadAnimation(Cat_sjl.this, R.anim.rotate_image));
}
@Override
public void onSearchViewClosed() {
searchView.startAnimation(AnimationUtils.loadAnimation(Cat_sjl.this, R.anim.rotate_image));
adapter.clear();
adapter.set(titulo.toArray(new String[0]));
}
});
anim
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate
android:duration="1500"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:startOffset="0"
android:toDegrees="360" />
</set>
If I'm not mistaken I should change the anim
and it will be ready, but which anim
one do I need?
It could be created with an animation, but I think it's tricky because it interacts with a LinearLayout and imageView pair. I recommend you use the following:
There is a repository that does what you are looking for:
Give him an oportunity.
Here is the Github repository for MaterialSearchView .