• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Please Help Me

Nits

Lurker
Hello,
This is Nitesh, I m new to Android Programming
I am writing a program for Image zoom-In-Out on Button Click.
Please Help me i m getting problems.

1. If I do Normal display, it do display both image and button but fails to change dimensions.

2. If I use Canvas to draw Image then i m not getting how to draw or make display button on Canvas.

these are my problems.
please Help Me.

Thanking You
 
Hello Thnx for your suggestion

this is what i found working. foll code work for Zoom In-Out image when we scroll.
but i want to make the same for button click. & i failed to show button.


package com.example.zoom;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Bitmap.Config;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.ArcShape;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.RemoteViews;


public class Zoom extends View{
public Drawable image,b;
private int zoomControler=20;
public RelativeLayout rl;
public View canvas,iv;
ViewGroup vg;
Button btn;
Canvas c;
public Zoom(Context context)
{
super(context);


iv = (Button) findViewById(R.id.Button01);
image=context.getResources().getDrawable(R.drawable.icon);

setFocusable(true);
}

@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.findViewById(R.id.Button01);
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;
}


}
 
Back
Top Bottom