Rotate a drawable (png) in 2D

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

Rotate a drawable (png) in 2D

Postby miguelo » Tue Dec 15, 2009 1:44 pm

Hi,

I saw on ApiDemos an example similar I like...(Graphics -> OpenGL -> Textured Triangle) in this example rotate a drawable in a texture triangle.

Is posible rotate only the drawable resource?...without a triangle and without repeat into the texture?...if i must create a texture to rotate a drawable...could be transparent? and could not repeat the drawable into?.

Conclusion: i wish rotate a transparent image (png) in an activity with a static background with text and other images. I suppose there must be an easy way to do...or not?

Thanks in advance and sorry for my english
miguelo
Freshman
Freshman
 
Posts: 6
Joined: Mon Nov 17, 2008 4:05 pm

Top

Re: Rotate a drawable (png) in 2D

Postby miguelo » Tue Dec 15, 2009 4:47 pm

Solution:

rotate_animation.xml:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <?xml version="1.0" encoding="utf-8"?>
  3.  
  4.  
  5.  
  6. <set xmlns:android="http://schemas.android.com/apk/res/android"
  7.  
  8.         android:shareInterpolator="false">
  9.  
  10.         <set android:interpolator="@android:anim/accelerate_interpolator">
  11.  
  12.                 <rotate android:fromDegrees="0" android:toDegrees="360"
  13.  
  14.                         android:toYScale="0.0" android:pivotX="50%" android:pivotY="50%"
  15.  
  16.                         android:startOffset="700" android:duration="4000" />
  17.  
  18.         </set>
  19.  
  20. </set>
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


RotationActivity.java:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class RotateAnimationActivity extends Activity {
  2.  
  3.  
  4.  
  5.     @Override
  6.  
  7.     protected void onCreate(Bundle savedInstanceState) {
  8.  
  9.         super.onCreate(savedInstanceState);
  10.  
  11.         setContentView(R.layout.reflect);
  12.  
  13.         ImageView myView= (ImageView) findViewById(R.id.myViewId);        
  14.  
  15.         Animation animation = AnimationUtils.loadAnimation(this, R.anim.rotate_animation);
  16.  
  17.         myView.startAnimation(animation);
  18.  
  19.     }
  20.  
  21.  
  22.  
  23. }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


Regards!
miguelo
Freshman
Freshman
 
Posts: 6
Joined: Mon Nov 17, 2008 4:05 pm

Top

Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 4 guests