Android: Why the layout changes when I delete the drawable-hdpi folder -
i developing layout 320dp devices. have layout-sw320dp have following code displaying 6 imagebuttons.
<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:elevation="4dp" > <!-- main content view --> <framelayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="match_parent" > <gridlayout android:layout_width="match_parent" android:layout_height="match_parent" android:rowcount="3" android:columncount="2" android:paddingtop="10dp" android:paddingleft="@dimen/activity_horizontal_margin"> <imagebutton android:layout_row="0" android:layout_column="0" android:padding="10dp" android:src="@drawable/info_image_button_90_90" android:id="@+id/info_image_button" /> <imagebutton android:layout_row="0" android:layout_column="1" android:padding="10dp" android:src="@drawable/matri_image_button_90_90" android:id="@+id/event_imgae_button" /> <imagebutton android:layout_row="1" android:layout_column="0" android:padding="10dp" android:src="@drawable/events_image_button_90_90" android:id="@+id/image_button_10" /> <imagebutton android:layout_row="1" android:layout_column="1" android:padding="10dp" android:src="@drawable/ann_image_button_90_90" android:id="@+id/image_button_11" /> <imagebutton android:layout_row="2" android:layout_column="0" android:padding="10dp" android:src="@drawable/events_image_button_90_90" android:id="@+id/image_button_20" /> <imagebutton android:layout_row="2" android:layout_column="1" android:padding="10dp" android:src="@drawable/events_image_button_90_90" android:id="@+id/image_button_21" /> </gridlayout> </framelayout> <!-- navigation drawer --> <listview android:layout_width="240dp" android:layout_height="match_parent" android:id="@+id/drawer_list_view" android:layout_gravity="start" android:background="@color/white" android:fitssystemwindows="true" /> </android.support.v4.widget.drawerlayout>
i have images (90x90) imagebutton in drawable-ldpi. till layout looks this
but when add folder drawable-hdpi have same images in drawable-ldpi, layout changes this
why layout changed? while having same device (nexus one) , same images (90x90)
if developing 320dpi, should xhdpi.
from developer.android.com:
a set of 6 generalized densities:
ldpi (low) ~120dpi mdpi (medium) ~160dpi hdpi (high) ~240dpi xhdpi (extra-high) ~320dpi xxhdpi (extra-extra-high) ~480dpi xxxhdpi (extra-extra-extra-high) ~640dpi
basically system tries find best match drawables. when had them in ldpi folder, well, choice - took them , scaled them xhdpi/ldpi = 320/120. when added same images in hdpi folder, became best match, scaled xhdpi/hdpi = 320/240, hence smaller size.
generally, if find size images , want consistent size across different densities, need keep ratio between them.
traditionally, mdpi considered standard, ratio of 1:1, , rest follows:
ldpi = 1 : 0.75 mdpi = 1 : 1 hdpi = 1 : 1.5 xhdpi = 1 : 2 xxhdpi = 1 : 3 xxxhdpi = 1 : 4
Comments
Post a Comment