简体   繁体   中英

Is Android Wear able to support animation

I am a new on Android Wear. Currently I am working on a project which is neccessary to send notifications to rotate an image on the Android Wear. I have tried to google for any same codes but to no avail.

Understand that Android Wear does not support AnimationUtil api, does it mean that it cannot animate rotating images? If able to support, is it possible to show some sample codes here?

Thanks.

Why don't you use setRotation? I used this for the second hand in my Wear app (battery efficient too!).

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

Yes, it's possible. Add this code in your wear app's Activity.

    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>

Hope this will help you buddy.. Thanks..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM