views:

39

answers:

2

I want to display a play button (ImageView) ontop of a thumbnail (another ImageView). How can I place UI controls ontop of each other?

Programatically or in XML?

+1  A: 

You can do this programatically & in XML - but XML is the most preferable way. Just choose a layout manager like RelativeLayout, and add your ImageViews to it like this:

<ImageView
    android:id="@+id/imageview_bottom"
    ... />
<ImageView
    android:id="@+id/imageview_ontop"
    ... />
mreichelt
perfect, easy solution, if XML is the way to go, then it's the way to go!
Sheehan Alam
Why would XML be the most preferable way :-/ ?
Pandoro
A: 

The FrameLayout is designed for layering multiple Views on top of each other.

Mayra
Yeah, it is - but it can do nothing more than that. This is why I didn't mention it. :)
mreichelt
Well, you can mix it with other layouts to do lots of things. It is often the layout you want if you are layering things, but you are right that RelativeLayout works also in this particular case.
Mayra