1

Je suis un nouveau sur Android Wear. Actuellement, je travaille sur un projet qui est nécessaire pour envoyer des notifications pour faire pivoter une image sur Android Wear. J'ai essayé de google pour les mêmes codes mais en vain. Comprendre qu'Android Wear ne prend pas en charge AnimationUtil API, cela signifie-t-il qu'il ne peut pas animer les images en rotation? Si capable de soutenir, est-il possible d'afficher quelques exemples de codes ici?Android Wear peut-il prendre en charge l'animation?

Merci.

Répondre

0

Oui, c'est possible. Ajoutez ce code dans l'Activité de votre application d'usure.

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> 

espère que cela vous aidera mon pote .. Merci ..

+1

J'ai essayé cet échantillon mais il est toujours incapable d'afficher la rotation sur mes vêtements. En passant, je cours l'usure sur l'émulateur, est-ce important? – user3464646

1

Pourquoi utilisez-vous pas setRotation? Je l'ai utilisé pour la deuxième main dans mon application Wear (batterie efficace aussi!).

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