Create a class "BitmapDrawable" which extends Drawable and pass the bitmap to the contructor. Then in draw() , draw the bitmap. Create the object of the "BitmapDrawable" class and add the object to the AnimationDrawable using addFrame()and set the duration in milliseconds(how much time you need to display the drawable). Then create a thread and call animationDrawable.start()
Hope this helps... Nithin On Feb 25, 9:34 am, CMF <manf...@gmail.com> wrote: > I have bitmap displayed on the top of the screen when the app is > started up. > When clicking on the bitmap, the image should move to the bottom of > the screen. > > I have read the AnimateDrawables from ApiDemos, but the animation is > done on a Drawable Object. If it can use on bitmap, it will be great! > > Here is my code > > public class HelloAndroid extends Activity { > /** Called when the activity is first created. */ > �...@override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > BitmapAnimation tv = new BitmapAnimation(this); > setContentView(tv); > } > > } > > public class BitmapAnimation extends View{ > private Bitmap myBitmap; > public BitmapAnimation(Context context) { > super(context); > BitmapFactory.Options opts = new > BitmapFactory.Options(); > opts.inScaled = false; > myBitmap = > BitmapFactory.decodeResource(getResources(), > R.drawable.icon, opts); > } > protected void onDraw(Canvas canvas) { > super.onDraw(canvas); > canvas.drawBitmap(myBitmap, 0, 0 ,new Paint()); > public boolean onTouchEvent(MotionEvent event){ > if(event.getX() < myBitmap.getWidth() && event.getY() < > myBitmap.getHeight()) > { > //do animation here > } > return true; > } > } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en