1
votes

I'm working on an application that the client wants to has the same looks on all supporting devices. This application will support Android 4.0.3 or above for the following devices.

  • mid-to-high end phone portrait (including Phablet)
  • 7" tablet portrait (same layout with phone)
  • 10" tablet landscape

If I create a layout like this

  • layout (mid-end phone, high-end phone, phablet and 7" tablet)
  • layout-sw720dp-land (for 10" tablet)

and define all the ui dimensions and drawable in

  • values-sw320dp, drawable-sw320dp (most of the mid end phone)
  • values-sw360dp, drawable-sw360dp (most of the high-end phone)
  • values-sw480dp, drawable-sw480dp (some phablet phone like Samsung Galaxy Mega)
  • values-sw600dp, drawable-sw600dp (7" tablet)
  • values-sw720dp, drawable-sw720dp (10" tablet)

My questions are

  1. will that covering all the devices I mentioned?
  2. values is equal to values-sw320dp, is that correct?
  3. device like Samsung Galaxy Tab 2 7" has an onscreen control so its dp is actually lower than 600dp. Then, in my case, it will load values and drawables from sw480dp, is it correct?

Thank you.

2
You have a lot of questions. You cover DP only, but what about sw and sh? Landscape vs. Portrait? There are lots of devices, so covering all of them is not a standard formula (if it were, wouldn't Google publish such a list?)user1932079
@JeremyMiller the dp list came from my research, I found that most of the high-end devices these day are at 360dpi while mid-end device (including high-end devices from few years ago, like Nexus 4) are at 320dpi. For the orientation and sh, the design from client are vertical scrolling for phone and horizontal stretching for tablet (this mean, for example the phone factor, I only have to concern about width while the height I'll just make it scrolling if the content won't fit it)Tar_Tw45
@AndrewT. can you answer the question? So that I can mark yours as the correct answer if there is no other answer or no one deny yours. Thanks!Tar_Tw45

2 Answers

2
votes

Will that covering all the devices I mentioned?

From the list given, it seems that you should already cover all the cases. Please take note that there is no hard line whether a device is a phone or tablet given its size/resolution. Here is a general guideline by Google:

To help you target some of your designs for different types of devices, here are some numbers for typical screen widths:

  • 320dp: a typical phone screen (240x320 ldpi, 320x480 mdpi, 480x800 hdpi, etc).
  • 480dp: a tweener tablet like the Streak (480x800 mdpi).
  • 600dp: a 7” tablet (600x1024 mdpi).
  • 720dp: a 10” tablet (720x1280 mdpi, 800x1280 mdpi, etc).

Values is equal to values-sw320dp, is that correct?

The device will use any resources that is the most suitable based on its qualifier. If a device has smallest width between 320dp-359dp, it will use both resources from /values-sw320dp and /drawables-sw320dp. If it's between 360dp-479dp, it will use the next one. Meanwhile, a general/default resource should be put in /values and /drawable (without qualifier).


Device like Samsung Galaxy Tab 2 7" has an onscreen control so its dp is actually lower than 600dp. Then, in my case, it will load values and drawables from sw480dp, is it correct?

Again, from Android developer's guide:

The smallestWidth of a device takes into account screen decorations and system UI. For example, if the device has some persistent UI elements on the screen that account for space along the axis of the smallestWidth, the system declares the smallestWidth to be smaller than the actual screen size, because those are screen pixels not available for your UI.

According to this definition, system UI such as soft-menu won't be included in the calculation. You're correct about the concept.


After all, you should test all your layouts with real devices/emulator and see the final result. By using emulator, you can specify the configuration easily for testing.

-1
votes

u have to follow this rules if u want to make design of all the device,

  1. Use maximum LinearLayout.
  2. Use weightSum of LinearLayout.
  3. For example,

     <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:background="@drawable/top_edit"
            android:weightSum="2" >
    
            <RelativeLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="left" >
    
                <Button
                    android:id="@+id/star"
                    android:layout_width="@dimen/star_width"
                    android:layout_height="match_parent"
                    android:background="@drawable/star_xml" />
            </RelativeLayout>
    
            <RelativeLayout
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="right" >
    
                <Button
                    android:id="@+id/more"
                    android:layout_width="@dimen/more_width"
                    android:layout_height="match_parent"
                    android:background="@drawable/more_xml" />
            </RelativeLayout>
        </LinearLayout>