Android Wear是否能够支持动画

时间:2014-08-27 07:43:44

标签: android android-activity android-animation wear-os android-wear-data-api

我是Android Wear的新手。目前,我正在开发一个项目,该项目需要发送通知以在Android Wear上旋转图像。我试图谷歌任何相同的代码但无济于事。

了解Android Wear不支持AnimationUtil api,是否意味着它无法为旋转图像制作动画?如果能够支持,是否可以在这里显示一些示例代码?

感谢。

2 个答案:

答案 0 :(得分:1)

为什么不使用setRotation?我在Wear应用程序中使用了这个(电池效率太高了!)。

imgSeconds = (ImageView) findViewById(R.id.imgsecond);
imgSeconds.setRotation(seconds*6);

答案 1 :(得分:0)

是的,这是可能的。  在您的磨损应用程序的活动中添加此代码。

    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>

希望这会帮助你的伙伴..谢谢..