I try to put a Background
in the app, something very simple to learn the use of canvas
andbitmaps
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 at the point (0,0) from canvas
which I have created, but of course the image does not occupy the entire screen (I suppose because of its size and others), what method or what type of I must do this scaling to get it to occupy the entire background, and of course, that it is scaled for any type of screen. All the best.
This code will help you