Android Base Multi Device Screen & Language Support

Multi Screen Support Screen Layout Classification Multi Lang Support Video Multi Screen Layout With Android Studio Video Create Drawables For Different Densities

Download Example Multi Device

Android Multi Device

Multi Screen Support

Android apps run on different devices that offer different sizes, densities and screen orientations in addition to being able to support different languages ??and cultures. The system itself tries to hide the complexity due to this heterogeneity by providing automatic adjustments at the user interface level and simplifying our work.

However in the development of an application we need to make adequate adjustments that allow us to have a better user experience depending on the screen.

For example the distribution the views may not be the same on screen small as medium or large or when we rotate our device we want that in landscape position is shown in one way and Portrait is organized in another. In addition, the automatic adjustments made by Android regarding the sizes may not be the desired ones, so we have to be able to vary the dimensions of our views also according to the characteristics of the screen of the target device.

In order to understand how the mechanism of adjustment in the user interfaces works for diferent devices we have to know that there is a real Physical Size for which measurement is considered the diagonal of the screen (inches) and a screen density directive that provides us information about the amount of pixels that can have that screen.

For simplicity, on Android all physical size of real screens is grouped into four generalized categories: small, normal, large and extra large. Regarding the subject of screen density is exactly the amount of pixels within a physical area of ??the screen, generally referred to as “dpi” (dots per inch). For example, a “low” density display has fewer pixels within a given physical area compared to a “normal” or “high” density display. For simplicity, on Android all densities of screens are grouped into six generalized categories: low, medium, high, extra high, extra extra and extra extra extra.

So there is two principal points to adjust. How the screen dimension affect to my components size and how see the quality of my images in the different resolutions.

How does the screen adjustment system work?

It makes a relation with respect to a preset device of “average” size, we will see later, the preset  type HVGA  has 320×480 Width x Height Pixels Resolution and 160dpi mpi.

Depth-independent pixels (dp)

At runtime, the system transparently handles any setting of the dp units, when necessary, according to the current density of the screen in use. Converting dp units to screen pixels is simple: px = dp * (dpi / 160). For example, on a 240 dpi screen, 1 dp is equal to 1.5 physical pixels. You should always use dp units when you define the UI of your application, to make sure that your UI is displayed properly on screens with different densities.

The following is a list of resource directories in an application that provides different layout designs for different screen sizes and different bitmap drawables for small, medium, high, and extra high density screens. you could use different size of the layout files in res folder and also vary for drawable images based on the density.

Specifies each screen configuration with which the application is compatible.

The Android system does not read the <compatible-screens> element manifest (neither at installation time nor at runtime). This item is for informational purposes only and can be used by external services (such as Google Play) to better understand application compatibility with specific screen configurations and allow filtering for users.

Caution: Normally, you should not use this element of manifest. Using this item can drastically reduce the potential user base for your application by not allowing users to install your application


By default, every time the screen configuration changes (orientation, keyboard hiding, screen size, …) the running activity is restarted onDestroy () and then onCreate () is called. To declare that your activity detects configuration changes, edit the corresponding <activity> element in the manifest file to include the android: configChanges attribute with a value that represents the configuration you want to handle. It is important to remember that when we have the configuration change manager active, the activity will not restart and only the listener in question will pass.

The possible values ??are listed in the documentation for the android attribute: configChanges (the most commonly used values ??are “orientation” to avoid reboots when changing the screen orientation and “keyboardHidden” to avoid reboots when keyboard availability changes). You can declare multiple settings in the separator attribute with a vertical bar. For example, the activity tracking manifest code that handles both the change of the screen orientation and the change of keyboard availability:

The method to execute on the activity:



Screen Layout Classification

In function of dps android has a base old definition for 4 type the screens:

Old way classification :


Screen characteristic Qualifier Description
Size small Resources for small size screens.
normal Resources for normal size screens. (This is the baseline size.)
large Resources for large size screens.
xlarge Resources for extra-large size screens.
Density ldpi Resources for low-density (ldpi) screens (~120dpi).
mdpi Resources for medium-density (mdpi) screens (~160dpi). (This is the baseline density.)
hdpi Resources for high-density (hdpi) screens (~240dpi).
xhdpi Resources for extra-high-density (xhdpi) screens (~320dpi).
xxhdpi Resources for extra-extra-high-density (xxhdpi) screens (~480dpi).
xxxhdpi Resources for extra-extra-extra-high-density (xxxhdpi) uses (~640dpi). Use this for the launcher icon only, see note above.
nodpi Resources for all densities. These are density-independent resources. The system does not scale resources tagged with this qualifier, regardless of the current screen’s density.
tvdpi Resources for screens somewhere between mdpi and hdpi; approximately 213dpi. This is not considered a “primary” density group. It is mostly intended for televisions and most apps shouldn’t need it—providing mdpi and hdpi resources is sufficient for most apps and the system will scale them as appropriate. If you find it necessary to provide tvdpi resources, you should size them at a factor of 1.33*mdpi. For example, a 100px x 100px image for mdpi screens should be 133px x 133px for tvdpi.
Orientation land Resources for screens in the landscape orientation (wide aspect ratio).
port Resources for screens in the portrait orientation (tall aspect ratio).

For example, the following application resource directories provide different layout designs for different screen sizes and different drawables. Use the mipmap/ folders for launcher icons.



From Android 3.2 the new way is based on the dps directly, both old and new way are nowdays working.

Screen configuration Qualifier values Description
smallestWidth Examples:
The fundamental size of a screen, indicated by the shortest dimension of the available screen area. Specifically, the smallest width of the device is the shortest height and the available width of the screen (you can also think of it as the “smallest possible width” for the screen).
Available screen width >Examples:
Specifies a minimum available width in dp units at which the resources should be used—defined by the value.
Available screen height Examples:
Specifies a minimum screen height in dp units at which the resources should be used—defined by the value.

Density of Drawable Images

The other point that we have to adjust is relative to how our graphics is going to be showed on different devices. This is shown in function of DPIs, android classifies the medium-density, high-density, extra-high-density, extra-extra-extra-high-density devices.

To create alternative bitmap drawables for different densities, you should follow the 3:4:6:8:12:16 scaling ratiobetween the six generalized densities. For example, if you have a bitmap drawable that’s 48×48 pixels for medium-density screens, all the different sizes should be:

  • 36×36 (0.75x) for low-density
  • 48×48 (1.0x baseline) for medium-density
  • 72×72 (1.5x) for high-density
  • 96×96 (2.0x) for extra-high-density
  • 144×144 (3.0x) for extra-extra-high-density
  • 192×192 (4.0x) for extra-extra-extra-high-density (launcher icon only; see note above)


Table for screen resolutions Vs Densities 

Default base device type

Low density (120), ldpi Medium density (160), mdpi High density (240), hdpi Extra-high-density (320), xhdpi
Small screen QVGA (240×320) 480×640
Normal screen WQVGA400 (240×400)
WQVGA432 (240×432)
HVGA (320×480) WVGA800 (480×800)
WVGA854 (480×854)
Large screen WVGA800** (480×800)
WVGA854** (480×854)
WVGA800* (480×800)
WVGA854* (480×854)
Extra-Large screen 1024×600 WXGA (1280×800)

 Example Apply to Real Devices

For Nexus 4 should load the same layout that Galaxy S3

Galaxy S3 Screen Size: 4.8 inch Screen Resolution: 1,280 x 720 pixels

And the configuration should be:

  1. For same layout landscape and portrait layout-sw360dp
  2. Only for landscape layout-sw360dp-land
  3. Only for portrait layout-sw360dp-port

Other similar devices:

  • LG Optimus 4X HD
  • HTC One X+

For Galaxy S4 should also compatible and load this layout

The response was in this entry: Android S3 layout vs Galaxy Nexus layout


Fragments is the complement from Android 4.0 to support for multiple screen configurations more easily and reusing our code cleanly. They are not objective of the Base Training, so we will see Android Fragments tutorial on advanced level for more information.


Multi Lang Support

The way to add multi language support to our projects is with strings values resources.

Following an example, basically we have to add the file strings.xml to the resources values folder and then for each key put an entry like:

You can edit directly over the xml file or with a visual translations editor that can be launched from the view of the file or from the layout view (see the pictures)



(Show how can edit translations from a layout view)

(Show how can edit translations from a layout view)

Scaping translations in strings.xml

Sometimes we need to insert especial character already existing in the XML data dictionary or in the Java language itself. If we need to escape, that means that we want to use characters that involve conflicts, the XML syntax itself (such as the & symbol) can be done as follows.

Special characters escaped in java with “\” as the carriage jump “\ n” or tab “\ t” can be written in the same way:


Params in strings.xml

The strings resources can be parametrizable via defining the order of the parameter and the type, 

For example for strings values we could wirte:

%1$d text... %2$d or %1$s text... %2$s for string variables.

then in the


an then in

Get translatoin with getString(), and apply parameters in order.


Default Language

Set by language. Always try to set the default language of the device as the language of my app, if not have that translation available set a default lang by code, e.g. English.

Next example shows how set a default lang programatically:


In the final example we can learn all this things in action with examples and code to download.

Great Job!.


Full Example

That pursues the following exercise, as show how affect the android qualifiers to the layouts. The idea is based on a simple view designed for viewing in portrait / vertical, when we move to landscape / horizontal, we modify the layout, this involves creating a new layout for each of the visualizations. In addition we will create a particular one for a specific language (ES). It is also possible, it is not usually done since this must be solved mainly with the translation system based on strings.xml explained above but in situations where culture / language / religion can affect the display of information we can use such filters to show organized information from left to right (as in the case of Middle Eastern countries) or if we wanted to show graphic resources determined according to the culture of a country.

At the first time we have to create another layout  depending on the characteristics we want to support.

Let’s define two cut-off points. One for smartphone devices (less than 5 inches) that we define for 360dp landscape up, one for tablets (greater than 7 inches) that we define landscape 600dp and up and another for only one ES language. Then we will see how each of the defined qualifiers behaves.

Android Studio Multi-Layout Qualifier Folders

Android Studio Multi-Layout Qualifier Folders

Video Multi Screen Layout With Android Studio

Create layouts for land orientation smartphones, tablets and lang support

Create the Default Layout

The default layout is used when none of the rules or qualifiers are applied, in our case would be that it is not a Spanish locality, the width in landscape is greater to 360dp or the width is greater to 600dp.

Following the default layout:


Create Layout for Lang Qualifier

Ok, as we can see in the video the lang qualifier set a layout only in portrait mode for all orientations but add the Spanish flag Image.


Create Layout for Medium Size Smartphone and  Land Orientation (w360dp-land)

In landscape we have added two real layouts one for the title and the other for placing a container that will contain the text boxes to the right and the buttons to the left. The container is constructed based on two “LinearLayout” in which it indicates that the distribution of the weights will be to 50%, property “android: layout_weight =”. 50 “, important detail so that it is always a proportional to screen size. The layout_weight is a number between 0-1 that indicate the space to occupy inside another container layout, as they will distribute the space the different layouts that are at the same level.


SmartPhone Portrait

SmartPhone Landscape

Qualifier for w360dp-land

The following devices hdp | tvdpi and de with is greater to 360



Create Layout for Tablet on Land Orientation

Qualifier for w600dp-land



 Code Of Activity

Here we have the code for the activity, pay attention to how compose the message with the orientation, resolution, densintry and others params.

The following sentence get from strings.xm resource the resolution_density_orientation resource and resolve the orientation, screen smallest and current thanks to configuration android object.


The code is the following (you have full code in the download example link):


Video Create Drawables For Different Densities

The standard procedures are:

The video shows how create the directories for the drawables in  hdpi and xhdpi.

  • Choose Project > app > scr > main
  • Right click “res”, choose “New” and choose “Android resource directory”


Once a directories has been created we have three images prepared:

(1) android_logo.png

(2) android_logo_hdpi.png

(3) android_logo_xhdpi.png

(above the default image android_logo)

(above the android_logo_hdpi)


Rename The Drawables

Move Each Drawable for each density to the specific folder

Finally this is the structure of the directories con 2 drawables qualifier  for hdpi and xhdpi is the following:

Now We can use the android_logo.png in ours layouts, we use it in the land layouts only for show in a three columns template.


Video Change Landscape Orientation on Tablet (w600dp-land)

Watch the change of layout and the drawable for the density of the device (in this case xhdpi)

Video Add Locale to strings.xml resource

Add The Translations

How add more translations for more locales


Video Test layout assigned to ES Locale



How to Support Multiple Screens

  • Explicitly state in the manifest what screen sizes your application supports. It´s not a good approach when we want our app  work in most of the devices. This option limits out publication only to screen devices listed!.
  • Provide different layouts for different screen sizes and orientations.
  • Different bitmap drawables and icons for different screen densities.
  • Remember that by default the system uses the appropriate alternative resource based on the size and density of the current screen, the system uses any specific resource of size and density provided in your application. This algorithm is not proportionate in function of each screen but is calculated based on an average HVGA device, let’s not expect 100% geometrically scaled growth.
  • Internationalizing our app is always a good practice but we must do it with quality translations and support the objectives that our development has.

  • Set by language. Always try to set the default language of the device as the language of my app, if not have that translation available set a default, eg English.

Fantastic job, let’s move on to the next chapter.


Download Example Multi-Device And I18N


All Downloads

git clone

Info Links

Portions of this page are reproduced from work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.



Leave a Reply

Social media & sharing icons powered by UltimatelySocial