Reputation: 110600
I have an ImageView
in my android layout. And I would like to add a 'decorator' image at the lower right corner of my image view.
Can you tell me how can I do it?
I am thinking of doing with a FramLayout with 2 image views as its child, but how can i make one image the lower right corner of another?
<FrameLayout>
<ImageView .../>
<ImageView .../>
</FrameLayout>
Upvotes: 0
Views: 1023
Reputation: 43412
You could create your own class that extends ImageView. It will always draw decorator over the ImageView content.
public class MyImage extends ImageView {
static Bitmap decorator;
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if(decorator==null)
decorator = BitmapFactory.decodeResource(getResources(), R.drawable.decorator);
canvas.drawBitmap(decorator, 0, 0, null);
}
public MyImage(Context context) {
super(context);
}
public MyImage(Context context, AttributeSet attrs) {
super(context, attrs, 0);
}
public MyImage(Context context, AttributeSet attrs, int params) {
super(context, attrs, params);
}
}
Upvotes: 1
Reputation: 2853
You probably want to be using a RelativeLayout
(Documentation) instead - it supports stacking views, and all you'd have to do is align the bottom and left of the overlay ImageView
with the bottom and left.
Upvotes: 3