I was wandering if anyone could help me with a little image scaling problem that I have while creating custom view (customized button)? So, I created a custom view class with custom constructor and few methods:
public class GamesButton extends View {
public int imageID;
public Bitmap image;
public GamesButton(Context context, AttributeSet attrs) {
super(context, attrs);
}
public GamesButton(Context context, int resImage) {
super(context);
this.imageID = resImage;
this.image = BitmapFactory.decodeResource(context.getResources(),imageID);
setFocusable(true);
setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// do something
}
});
setClickable(true);
}
public void onDraw(Canvas canvas) {
Paint textPaint = new Paint();
textPaint.setColor(Color.BLACK);
canvas.drawBitmap(image,0 , 0,null);
}
.
.
.
I've also overridden onMeaure() and others, but my custom view size is not the issue here.
The problem is the Bitmap image that I use as a button or as a surface that you click on. I can't scale it so that you can see the whole image on screen.
Is there a way to deal with this?
Thank you!