


weldrian wrote:zooming.javaUsing java Syntax Highlighting
import android.app.Activity; import android.os.Bundle; public class zooming extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(new Zoom(this)); } }Parsed in 0.031 seconds, using GeSHi 1.0.8.4
Zoom.javaUsing java Syntax Highlighting
import android.content.Context; import android.graphics.Canvas; import android.graphics.drawable.Drawable; import android.view.KeyEvent; import android.view.View; public class Zoom extends View { private Drawable image; private int zoomControler=20; public Zoom(Context context) { super(context); image=context.getResources().getDrawable(R.drawable.icon); setFocusable(true); } @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); //here u can control the width and height of the images........ this line is very important image.setBounds((getWidth()/2)-zoomControler, (getHeight()/2)-zoomControler, (getWidth()/2)+zoomControler, (getHeight()/2)+zoomControler); image.draw(canvas); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if(keyCode==KeyEvent.KEYCODE_DPAD_UP)// zoom in zoomControler+=10; if(keyCode==KeyEvent.KEYCODE_DPAD_DOWN) // zoom out zoomControler-=10; if(zoomControler<10) zoomControler=10; invalidate(); return true; } } Parsed in 0.034 seconds, using GeSHi 1.0.8.4
Him Thx for your instruction above, but im a very new developer, can you kindly explaint step by step?
Many thanks =)
another question is how can i upload the picure into the android app.

venkat wrote:Hi ben, it is very easy to Zoom in and zoom out Images. take a look here
using UP and Down Arrow keys , u can zoom in and zoom out the images.
zooming.javaUsing java Syntax Highlighting
import android.app.Activity; import android.os.Bundle; public class zooming extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(new Zoom(this)); } }Parsed in 0.034 seconds, using GeSHi 1.0.8.4
Zoom.javaUsing java Syntax Highlighting
import android.content.Context; import android.graphics.Canvas; import android.graphics.drawable.Drawable; import android.view.KeyEvent; import android.view.View; public class Zoom extends View { private Drawable image; private int zoomControler=20; public Zoom(Context context) { super(context); image=context.getResources().getDrawable(R.drawable.icon); setFocusable(true); } @Override protected void onDraw(Canvas canvas) { // TODO Auto-generated method stub super.onDraw(canvas); //here u can control the width and height of the images........ this line is very important image.setBounds((getWidth()/2)-zoomControler, (getHeight()/2)-zoomControler, (getWidth()/2)+zoomControler, (getHeight()/2)+zoomControler); image.draw(canvas); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if(keyCode==KeyEvent.KEYCODE_DPAD_UP)// zoom in zoomControler+=10; if(keyCode==KeyEvent.KEYCODE_DPAD_DOWN) // zoom out zoomControler-=10; if(zoomControler<10) zoomControler=10; invalidate(); return true; } } Parsed in 0.038 seconds, using GeSHi 1.0.8.4
regards,
venkat

But the problem is I cannot see any changes when i use the application on HTC desire. How do i use this in the phone??? 



Users browsing this forum: No registered users and 9 guests