android - how can fit elements scale at different phone screens -


i wanna set image view specific backgorund position, set @ 1 type of android phone nexus 4

layout design in nexuas 4

but change position when screen changed in other anroid phone nexus 10

enter image description here

i searched @ web find solution , found set percentage of elemnts better way can set same scale @ different screens tried use different layout design tablelayout, gridlayout,linearlayout , others, can't set position of anroid smart phone @ same,

here relativelayout code:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:tools="http://schemas.android.com/tools"     android:id="@+id/relativelayout1"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:background="@drawable/test_backside"     >      <imageview         android:layout_width="1920dp"         android:layout_height="1080dp"         android:id="@+id/bgtopleftcorner"         android:src="@drawable/test_bg"         />      <imageview         android:layout_width="130dp"         android:layout_height="130dp"         android:src="@drawable/test_horizonal_layer"         android:layout_weight="30"         android:id="@+id/imageview5"         android:layout_alignparenttop="true"         android:layout_alignparentleft="true"         android:layout_alignparentstart="true"         android:layout_marginleft="44dp"         android:layout_marginstart="44dp" />      <imageview         android:layout_width="80dp"         android:layout_height="80dp"         android:src="@drawable/test_circle_1"         android:layout_marginright="36dp"         android:layout_marginend="36dp"         android:id="@+id/imageview7"         android:layout_below="@+id/imageview5"         android:layout_toleftof="@+id/imageview6"         android:layout_tostartof="@+id/imageview6" />      <imageview         android:layout_width="80dp"         android:layout_height="80dp"         android:src="@drawable/test_circle_2"         android:layout_weight="30"         android:id="@+id/imageview6"         android:layout_aligntop="@+id/imageview7"         android:layout_centerhorizontal="true" />      <imageview         android:layout_width="80dp"         android:layout_height="80dp"         android:src="@drawable/test_circle_3"         android:layout_weight="30"         android:id="@+id/imageview3"         android:layout_aligntop="@+id/imageview6"         android:layout_toleftof="@+id/imageview"         android:layout_tostartof="@+id/imageview"         android:layout_marginright="17dp"         android:layout_marginend="17dp" />      <imageview         android:layout_width="130dp"         android:layout_height="130dp"         android:src="@drawable/test_vertical_layer"         android:layout_weight="30"         android:id="@+id/imageview"         android:layout_marginbottom="43dp"         android:layout_alignparentbottom="true"         android:layout_alignparentright="true"         android:layout_alignparentend="true" /> </relativelayout> 

yeah, said setting percentage good, find screen width , height in activity/fragment class, , set width , height of each element in relative layout giving them width (x*screenwidth)/100.

this solve problem.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -