For showing image in frame there are two ways to do so
- Set Background Image or Color to show image is in Frame
- Set Masking
For setting BackGround :
<ImageView
android:id = "@+id/imageItem"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:adjustViewBounds = "true"
android:scaleType = "center"
android:padding = "5dp"
android:background = "#FFFFFF"
android:contentDescription = "@null" />
For Masking check following code :
ImageView mImageView= (ImageView)findViewById(R.id.imageview_id);
Bitmap original = BitmapFactory.decodeResource(getResources(),R.drawable.content_image);
Bitmap mask = BitmapFactory.decodeResource(getResources(),R.drawable.mask);
Bitmap result = Bitmap.createBitmap(mask.getWidth(), mask.getHeight(), Config.ARGB_8888);
Canvas mCanvas = new Canvas(result);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
mCanvas.drawBitmap(original, 0, 0, null);
mCanvas.drawBitmap(mask, 0, 0, paint);
paint.setXfermode(null);
mImageView.setImageBitmap(result);
mImageView.setScaleType(ScaleType.CENTER);
mImageView.setBackgroundResource(R.drawable.background_frame);
If you want to show color as background then first option will be much better and efficient too.