I'm trying to find out a way to align 2 images. The first image the border image (like a polaroid) and the second a picture. The picture should start in the corner of the border (around 20dp from left and top of the real border image) but that distance varies on what screen you have...
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="@drawable/border" />
</RelativeLayout>
This is what I get now:
The hardest thing is that the image shouldn't pop out the border image and the background behind the whole view (border + image) is variable!
I had to deal with a similar issue, back_img, img, text. I could deal with it in a really crappy way through styles (for every different screen size), but is the only thing i found that worked...
I set a LinearLayout and put the 3 imgs inside another LinearLayout
In the Styles, something like this:
So, you set Img1 size with a little margin (i found out that sometimes you need that margin in Imgs), and the second one with negative IMG1 width+rightMargin and in case of need, the text.
I think you should make your border image a 9-patch: http://developer.android.com/guide/developing/tools/draw9patch.html
Your best bet is to use the "border" image as the background drawable of the layout and then position your image on that layout:
I haven't tested this just now, but it's approximately what you would do.