Search code examples
androidsizescreenandroid-screen-supportmdpi

how to distinguish two different android mdpi phones


Im trying to write app witch will look similar on all (or most) android phones. I have a problem with two phones: Samsung Galaxy Ace 2 and Samsung Galaxy mini 2. Layout that takes whole screen in galaxy ace is too large for galaxy mini.

First I tried to specify different dimens for ldpi and mdpi, but it appeared that both phones used mdpi values. Then I was trying too distinguish them by screen sizes and made folder values-normal-mdpi. I thought that ace should be "large", it has 480x800 resolution and should be large accordinng to documentation: Supporting Multiple Screens. However both phones take values from the "normal-mdpi" folder. On the other hand I have seen application that look identical on both phones, how can I do this?

Edit:

imagine I have a very simple layout only with simple views:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
    android:id="@+id/textView4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" />

<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" />

<Button
    android:id="@+id/button3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" />

<Button
    android:id="@+id/button4"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" />

<Button
    android:id="@+id/button5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" />

<TextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge" />

<Button
    android:id="@+id/button6"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Button" /></LinearLayout>

The last button is not visible on smaller phone. What shoud I do if I want this to look identical on both?


Solution

  • Well, it turns out that none of the two is an mdpi device:
    Samsung Galaxy Ace 2: WVGA (480x800) resolution (about 244 dpi) = hdpi
    Samsung Galaxy Mini 2: QVGA (240×320) resolution (about 127 dpi) = ldpi

    So, the drawable folders for your graphics should be:
    res/drawable-ldpi
    res/drawable-hdpi

    Please note that you should provide pngs at the proper resolutions (120 and 240 dpi).
    You can choose to provide a normal resolution graphics (160 dpi, which is mdpi) and it will be scaled to 120 dpi (0.75x) for ldpi devices and to 240dpi (2.0x) for hdpi devices