android - What is a correct way to place image over ImageView? -


i'm novice in android development , still can't understand how sizing works different layouts. want place preview of book template:

book_template

i've tried implement using framelayout. idea center of preview image center of png background is. here code:

<framelayout   android:layout_width="wrap_content"   android:layout_height="wrap_content"   android:layout_weight=".5" >    <imageview     android:id="@+id/imageview1"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:src="@drawable/book_frame" />   <imageview     android:id="@+id/previewimage"     android:layout_width="83dp"     android:layout_height="83dp"     android:layout_gravity="center_vertical|center_horizontal"     android:src="@drawable/abs__ab_bottom_solid_dark_holo" /> </framelayout> 

the result in layout builder want be:

emulator_result

on real phone different:

phone_result

i think on other resolutions differ both variants. question how synchronize these images after resizing , distortions preview fit cover correctly? possible solution remove border image , place on previewimage instead. there several similar usecases in application border can't removed, i'd find out universal solution of them.

you have answer in question.

what happening in case image size matter different screen resolution.

hard-coded things gives weird result in case android:layout_width="83dp" android:layout_height="83dp" piece of code.

check link guide manage drawables different screens.

and here link


Comments