android - Filling the layout of different size -
in app adding images. using dp measurements. when see test in different sizes available in eclipse, see shown different in different devices.
(see lollipop filled different length).
please let me know avoid , create similar look-and-feel in devices
following layout.
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:weightsum="15" android:orientation="vertical"> <linearlayout android:id="@+id/ll0" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="5" android:orientation="horizontal" > <linearlayout android:id="@+id/ll1" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="4" android:orientation="vertical" > <linearlayout android:id="@+id/ll1a" android:layout_weight="3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <imagebutton android:id="@+id/imoption1" android:layout_width="90dp" android:layout_height="90dp" android:layout_gravity="center" android:background="@drawable/repeat" /> </linearlayout> <linearlayout android:id="@+id/ll1b" android:layout_weight="3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <imagebutton android:id="@+id/imoption2" android:layout_width="90dp" android:layout_height="90dp" android:layout_gravity="center" android:background="@drawable/repeat"/> </linearlayout> <linearlayout android:id="@+id/ll1c" android:layout_weight="3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <imagebutton android:id="@+id/imoption3" android:layout_width="90dp" android:layout_height="90dp" android:layout_gravity="center" android:background="@drawable/repeat"/> </linearlayout> </linearlayout> <linearlayout android:id="@+id/ll2" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="4" android:orientation="vertical" > <linearlayout android:id="@+id/ll2a" android:layout_weight="3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <imagebutton android:id="@+id/imoption4" android:layout_width="90dp" android:layout_height="90dp" android:layout_gravity="center" android:background="@drawable/repeat" /> </linearlayout> <linearlayout android:id="@+id/ll2b" android:layout_weight="3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <imagebutton android:id="@+id/imoption5" android:layout_width="90dp" android:layout_height="90dp" android:layout_gravity="center" android:background="@drawable/repeat"/> </linearlayout> <linearlayout android:id="@+id/ll2c" android:layout_weight="3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <imagebutton android:id="@+id/imoption6" android:layout_width="90dp" android:layout_height="90dp" android:layout_gravity="center" android:background="@drawable/repeat"/> </linearlayout> </linearlayout> <linearlayout android:id="@+id/ll3" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="4" android:orientation="vertical" > <linearlayout android:id="@+id/ll3a" android:layout_weight="3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <imagebutton android:id="@+id/imoption7" android:layout_width="90dp" android:layout_height="90dp" android:layout_gravity="center" android:background="@drawable/repeat" /> </linearlayout> <linearlayout android:id="@+id/ll3b" android:layout_weight="3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <imagebutton android:id="@+id/imoption8" android:layout_width="90dp" android:layout_height="90dp" android:layout_gravity="center" android:background="@drawable/repeat"/> </linearlayout> <linearlayout android:id="@+id/ll3c" android:layout_weight="3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <imagebutton android:id="@+id/imoption9" android:layout_width="90dp" android:layout_height="90dp" android:layout_gravity="center" android:background="@drawable/repeat"/> </linearlayout> </linearlayout> <linearlayout android:id="@+id/ll4" android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="3" android:weightsum="9" android:background="#ffff99" android:orientation="vertical" > <linearlayout android:id="@+id/ll4a" android:layout_alignparentleft="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <imageview android:id="@+id/ivdisplayarea" android:layout_width="wrap_content" android:layout_height="wrap_content" android:scaletype="centercrop" android:layout_gravity="center" android:background="@drawable/repeat"/> </linearlayout> </linearlayout> </linearlayout> <linearlayout android:id="@+id/ll5" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="10" android:orientation="horizontal"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:gravity="center" android:background="#ff6633" android:text="reward account " android:textcolor="#ffffff" android:textstyle="bold" /> <imagebutton android:id="@+id/breward1" android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center" android:layout_marginleft="10dp" android:background="@drawable/lollipop" /> <imagebutton android:id="@+id/breward2" android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center" android:layout_marginleft="7dp" android:background="@drawable/lollipop" /> <imagebutton android:id="@+id/breward3" android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center" android:layout_marginleft="7dp" android:background="@drawable/lollipop" /> <imagebutton android:id="@+id/breward4" android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center" android:layout_marginleft="7dp" android:background="@drawable/lollipop" /> <imagebutton android:id="@+id/breward5" android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center" android:layout_marginleft="7dp" android:background="@drawable/lollipop" /> <imagebutton android:id="@+id/breward6" android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center" android:layout_marginleft="7dp" android:background="@drawable/lollipop" /> <imagebutton android:id="@+id/breward7" android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center" android:layout_marginleft="7dp" android:background="@drawable/lollipop" /> <imagebutton android:id="@+id/breward8" android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center" android:layout_marginleft="7dp" android:background="@drawable/lollipop" /> <imagebutton android:id="@+id/breward9" android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center" android:layout_marginleft="7dp" android:background="@drawable/lollipop" /> <imagebutton android:id="@+id/breward10" android:layout_width="30dp" android:layout_height="30dp" android:layout_gravity="center" android:layout_marginleft="7dp" android:background="@drawable/lollipop" /> </linearlayout> </linearlayout>
this correct behavior. android works make sure graphics items remain same physical size regardless of screen density or screen size.
so, if choose button graphics image intended size of person's fingertip, graphic should displayed exact same physical size (i.e. size in inches) regardless of device characteristics.
if prefer screen laid out in such way looks same on devices, , scaled same bigger or smaller depending on screen size, there 2 ways this:
- instead of using density-independent-pixels "
dip
" (or equivalent "dp
"), use scale-independent-pixels "sip
" (or equivalent "sp
" - scale system font size) or "px
" (for pixels) define graphics component sizes. - instead of adding image "res/drawable" folder, add different size images same filenames various "res/drawable-ldpi", "res/drawable-mdpi", "res/drawable-hdpi", , "res/drawable-xhdpi" folders.
you have experiment image sizes right, ratios defined here: launcher icons: size , format
Comments
Post a Comment