In your case you are extending view
however if you use built in views or even your view which holds just the
image.
then u can setanimation and startanimation
TranslateAnimation animation = new TranslateAnimation(
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, 0.0f,
Animation.RELATIVE_TO_PARENT, -0.3f,
Animation.RELATIVE_TO_PARENT, -0.15f
);
animation.setDuration(2000);
animation.setFillAfter(true);
// animation.setZAdjustment(Animation.ZORDER_BOTTOM);
//i2.setAnimation(animation);
i2.startAnimation(animation);
here i2 is an imageview
Google it u will find lots of animation examples.
Hope this helps
On Thu, Feb 25, 2010 at 11:17 AM, CMF <[email protected]> wrote:
> Hi, do you have an explicit example? I don't know what are the
> relationships between the BitmapAnimation View , the main class and
> the Drawable class......
>
> On Feb 25, 1:09 pm, Nithin <[email protected]> wrote:
> > 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<[email protected]> 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 [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en