Resource images are placed under <project_dir>/res/drawable
Using a resource image in an image view – XML example
< ImageView
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:tint = "#55ff0000"
android:src = "@drawable/my_image_name" />
|
Using a resource image in an image view – Code Example
((ImageView)findViewById(R.id.myImageView)).setImageResource(R.drawable.my_image_name);
|
Turning the resource image to a Bitmap object
Bitmap bitmap = BitmapFactory.decodeResource(view.getResources(),R.drawable.my_image_name);
|
Drawing the bitmap on a canvas object
canvas.drawBitmap(bitmap, x, y, null );
|
Clearing the bitmap data from the memory