汉堡菜单图标可跨Android中的动画 [英] Hamburger menu icon to cross animation in Android
本文介绍了汉堡菜单图标可跨Android中的动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将菜单图标替换为十字图标,但是我不知道有比在ImageView中替换源代码更好的解决方案,而且我找不到能转换图像的已完成库。
I'm trying to replace menu icon with cross icon, but I don't know better solution than replacing source in ImageView and futher more I cannot find done libraries which converts images.
任何帮助将不胜感激。
Any help will be appreciateg.
推荐答案
对于动画,您可以使用以下代码:
For animation you can use this code:
public static void ImageViewAnimatedChange(Context c, final ImageView v, final Bitmap new_image) {
final Animation anim_out = AnimationUtils.loadAnimation(c, android.R.anim.fade_out);
final Animation anim_in = AnimationUtils.loadAnimation(c, android.R.anim.fade_in);
anim_out.setAnimationListener(new Animation.AnimationListener()
{
@Override public void onAnimationStart(Animation animation) {}
@Override public void onAnimationRepeat(Animation animation) {}
@Override public void onAnimationEnd(Animation animation)
{
v.setImageBitmap(new_image);
anim_in.setAnimationListener(new Animation.AnimationListener() {
@Override public void onAnimationStart(Animation animation) {}
@Override public void onAnimationRepeat(Animation animation) {}
@Override public void onAnimationEnd(Animation animation) {}
});
v.startAnimation(anim_in);
}
});
v.startAnimation(anim_out);
}
也可以看看viewflipper https://stackoverflow.com/a/19635874/5907003
Also have a look at viewflipper https://stackoverflow.com/a/19635874/5907003
祝你好运!
这篇关于汉堡菜单图标可跨Android中的动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文