问题描述
是否有可能在动作条动画(旋转)的应用程序图标。不是菜单项,但在屏幕的左侧的应用程序图标。
Is it possible to animate(rotate) the application icon in the actionbar. Not the menuItems but the application icon on the left side of the screen.
我有一个圆形的标志我的应用程序,我需要通过为应用程序运行缓慢,并且无限期地转动它,只要它更有活力。
I have a circular logo for my app and I need to make it more dynamic by rotating it slowly and indefinitely as long as the app is running.
在此先感谢...快乐编码
Thanks in Advance...Happy Coding
推荐答案
操作栏接受绘制对象
的图标,因此你可以使用 AnimationDrawable
和资源定义动画帧。通过看可绘制动画 Android的文档了解如何创建和使用 AnimationDrawable
。
Action bar accepts Drawable
for an icon, hence you can use AnimationDrawable
and define your animation frames in resources. Look through Drawable Animation android docs to understand how to create and use AnimationDrawable
.
另一种方法是应用动画的主页图标图像图。
Another way is to apply animation to an home icon image view.
定义动画RES /动画/ icon_rotate.xml
Define animation in res/anim/icon_rotate.xml
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="0"
android:toDegrees="360"
android:pivotY="50%"
android:pivotX="50%"
android:duration="1000"/>
访问操作栏图标的图像从你的活动的onCreate
方法,设置动画视图。注意:您可能希望与插补器来播放和重复计数这个动画
Access action bar icon image view from onCreate
method of your activity and set an animation. Note: you may want to play with interpolator and repeat count for this animation.
Animation a = AnimationUtils.loadAnimation(this, R.anim.icon_rotate);
findViewById(android.R.id.home).startAnimation(a);
这篇关于动画中的动作条的应用程序图标或标志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!