我是Android Wear的新手。目前,我正在开发一个需要发送通知以旋转Android Wear上的图像的项目。我试图谷歌任何相同的代码,但无济于事。Android Wear是否能够支持动画
了解Android Wear不支持AnimationUtil api,是否意味着它无法为旋转图像添加动画效果?如果能够支持,是否有可能在这里显示一些示例代码?
谢谢。
我是Android Wear的新手。目前,我正在开发一个需要发送通知以旋转Android Wear上的图像的项目。我试图谷歌任何相同的代码,但无济于事。Android Wear是否能够支持动画
了解Android Wear不支持AnimationUtil api,是否意味着它无法为旋转图像添加动画效果?如果能够支持,是否有可能在这里显示一些示例代码?
谢谢。
是的,这是可能的。 将此代码添加到您的穿着应用的活动中。
public class Animate extends Activity
{
Animation rotate;
@Override
protected void onCreate(Bundle savedInstanceState)
{
requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.animate);
final WatchViewStub stub = (WatchViewStub) findViewById(R.id.mainmenu_viewstub);
stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener()
{
@Override
public void onLayoutInflated(WatchViewStub stub)
{
rotate = = AnimationUtils.loadAnimation(Animate.this,
R.anim.rotate);
ImageView tip = (ImageView) findViewById(R.id.tip);
//Write the below line of code to animate image at the place where you are getting the //notification.
tip.startAnimation(rotate);
}
});
}
}
rotate.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<rotate android:fromDegrees="0"
android:toDegrees="360"
android:pivotX="50%"
android:pivotY="50%"
android:duration="600"
android:repeatMode="restart"
android:repeatCount="infinite"
android:interpolator="@android:anim/cycle_interpolator"/>
</set>
希望这将帮助你哥们..谢谢..
你为什么不使用setRotation?我用我的Wear应用程序中的第二只手(电池效率太高!)。
imgSeconds = (ImageView) findViewById(R.id.imgsecond);
imgSeconds.setRotation(seconds*6);
我试过这个样品,但它仍然无法显示我的磨损旋转。顺便说一句,我在模拟器上运行磨损,这有什么关系吗? – user3464646 2014-08-27 18:00:55