0

I am developing an app which run on multiple phones when i test it on a device which is of 5 inch screen but it's DPI level is 186 app layout does not look good.So what type of layout folder we must use if screen size is large but DPI is LOW

i have already gone through here

Please suggest something

Tarun Sharma
  • 601
  • 3
  • 13
  • 31
  • http://stackoverflow.com/questions/22728159/creating-multi-screen-support-app-android – Naveen Tamrakar Jan 15 '15 at 07:48
  • check out these links..http://stackoverflow.com/questions/16706076/font-size-and-images-for-different-device/16910589#16910589 http://stackoverflow.com/questions/12242111/application-skeleton-to-support-multiple-screen http://stackoverflow.com/questions/7587854/is-there-a-list-of-screen-resolutions-for-all-android-based-phones-and-tablets – M S Gadag Jan 15 '15 at 07:49

2 Answers2

0

You have to provide Alternative Resources to support specific device configurations. the official doc says

For instance, you should include alternative drawable resources for different screen densities and alternative string resources for different languages. At runtime, Android detects the current device configuration and loads the appropriate resources for your application.

Just to summarize the link

  1. Create a new directory in res/ named in the form <resources_name>-<config_qualifier>. <resources_name> is the directory name of the corresponding default resources

    <qualifier> is a name that specifies an individual configuration for which these resources are to be used

  2. Save the respective alternative resources in this new directory. The resource files must be named exactly the same as the default resource files.

For example, here are some default and alternative resources:

res/
    drawable/   
        icon.png
        background.png    
    drawable-hdpi/  
        icon.png
        background.png  

This way, the resource ID that you use to reference the icon.png or background.png image is always the same, but Android selects the version of each resource that best matches the current device, by comparing the device configuration information with the qualifiers in the resource directory name.

However , you should keep in mind name rules below:

Qualifier name rules

  1. You can specify multiple qualifiers for a single set of resources, separated by dashes. For example, drawable-en-rUS-land applies to US-English devices in landscape orientation.
  2. The qualifiers must be in the order listed in table 2. For example:

    Wrong: drawable-hdpi-port/

    Correct: drawable-port-hdpi/

  3. Alternative resource directories cannot be nested. For example, you cannot have res/drawable/drawable-en/

  4. Values are case-insensitive. The resource compiler converts directory names to lower case before processing to avoid problems on case-insensitive file systems. Any capitalization in the names is only to benefit readability

  5. Only one value for each qualifier type is supported. For example, if you want to use the same drawable files for Spain and France, you cannot have a directory named drawable-rES-rFR/. Instead you need two resource directories, such as drawable-rES/ and drawable-rFR/, which contain the appropriate files. However, you are not required to actually duplicate the same files in both locations. Instead, you can create an alias to a resource.

Here is a great official doc for How Android Finds the Best-matching Resource .

enter image description here

Here is also a Good answer and another good one for providing alternative resources

Community
  • 1
  • 1
Shubhang Malviya
  • 1,525
  • 11
  • 17
0

The problem happens because a lot of android API methods deals with the floating point of the applied attribute, So, to solve the problem, leave the layouts created as it is all in it's regular folders, and then , when applying some attribute to a view, make sure to apply that attribute through run-time, and make sure this attribute is converted to it's floating point using the following method:

float new_value = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, old_value, getResources().getDisplayMetrics());

this will give you a fixed layouts behavior among several DPIs.

Muhammed Refaat
  • 8,914
  • 14
  • 83
  • 118