Moving an image in the Emulator

Put your problem here if it does not fit any of the other categories.

Moving an image in the Emulator

Postby Tikloo » Wed Feb 27, 2008 5:10 am

Hello,

I am new to Android. I would like to move my image (.png) from left to right and top to bottom of the emulator. I am trying to develop an animation game. Can someone help me in giving me the code of how to make this happen?
Tikloo
Freshman
Freshman
 
Posts: 5
Joined: Wed Feb 27, 2008 4:36 am

Top

Postby plusminus » Wed Feb 27, 2008 11:06 am

Hello tikloo,

Animations can be done similar to this:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <set android:shareInterpolator="true"
  2.  
  3.     android:interpolator="@android:anim/accelerate_interpolator">
  4.  
  5.  
  6.  
  7.     <translate android:toYDelta="-100"
  8.  
  9.               android:fillAfter="true"
  10.  
  11.               android:duration="800"
  12.  
  13.               android:startOffset="1600"/>
  14.  
  15. </set>
Parsed in 0.001 seconds, using GeSHi 1.0.8.4

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. // Hook into the object to be animated.
  2.  
  3. TextView animWindow = (TextView)findViewById(R.id.anim);
  4.  
  5.  
  6.  
  7. // Load the animation from XML (XML file is res/anim/move_animation.xml).
  8.  
  9. Animation anim = AnimationUtils.loadAnimation(AnimationSample.this, R.anim.move_animation);
  10.  
  11. anim.setRepeatMode(Animation.NO_REPEAT);
  12.  
  13.  
  14.  
  15. // Play the animation.
  16.  
  17. animWindow.startAnimation(anim);
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Setting a small gif as a pointer to the button widget

Postby Tikloo » Tue Mar 04, 2008 6:07 am

Hi plusminus,

Thank you so much for your code sample. I have done the job successfully.

I am struck now at one point. I need your help to solve it.

I have say 3 Imagebuttons in my page.

a) I need a gif to point the first button when the page is getting loaded.
Kindly do help me out.

b) Also, i want the Imagebutton to set normally with the background page.The problem I face is the when the image button is set,it has a white background.


Help me pls!
Tikloo
Freshman
Freshman
 
Posts: 5
Joined: Wed Feb 27, 2008 4:36 am

Re: Setting a small gif as a pointer to the button widget

Postby plusminus » Tue Mar 04, 2008 1:35 pm

Hello Tikloo,

no problem :)

But this time I can't understand your questions properly.
What do you mean with "point to":
Tikloo wrote: a) I need a gif to point the first button when the page is getting loaded.


You mean: "When the ImageButton is selected i don't want it to highlight with a white background, but transparent" ?
Tikloo wrote: b) Also, i want the Imagebutton to set normally with the background page.The problem I face is the when the image button is set,it has a white background.


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

explanatiion

Postby Tikloo » Wed Mar 05, 2008 3:19 am

Hi Plusminus,

Thank you for ur immediate response.

I will explain the question.

1) I want to use a gif as a cursor point for this particular page alone.When I scroll through the buttons say moving down while selecting or moving up the image should point to the image button currently having the focus.

2) I am trying to solve this problem. I will comeback to you once if I cant.

thanks in advance.
Tikloo
Freshman
Freshman
 
Posts: 5
Joined: Wed Feb 27, 2008 4:36 am

Postby plusminus » Wed Mar 05, 2008 9:46 am

Hello Tikloo,

remember that there is no cursor on an Android Device!
i.e. On windows mobile you only have a cursor, when you attach an external mouse to your device.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: MSNbot Media and 18 guests