I try to put a Background
in the app, something very simple to learn the use of canvas
and bitmaps
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(new Vista(this));
}
public class Vista extends View{
public Vista(Context context ){
super(context);
}
protected void onDraw(Canvas canvas){
Paint mipincel = new Paint();
Bitmap res = BitmapFactory.decodeResource(getResources(),R.drawable.grassbg1);
res.
canvas.drawBitmap(res,0,0,null);
}
}
Well, I understand that with canvas.drawBitmap(res,0,0,null)
I am placing my image in the point (0,0) of the canvas
that I have created, but of course the image does not occupy the whole screen (I guess because of the size it has and other), what method or what type of that must do to get it to occupy the entire background, and of course, that is scaled for any type of screen. Greetings.