Android Learning Note: App screen adaptation related

Source: Internet
Author: User

When it comes to Android development, there is no need to pull the screen to fit the problem, why should the screen fit? The reason is very simple, because the Android phone-related device model too much (according to statistics, 2012 supported Android devices a total of 3997, 2013 reached 11868, up to 18796 in 2014, now will be more), different settings screen size is different, If we use a single way to treat all mobile phones, the results can be imagined! So we need to do a screen fit for different devices.

When it comes to dimensions, we're going to relate the concepts:

1, screen size: refers to the length of the device screen diagonal, generally in inches (inch) units,

2, screen resolution: refers to the screen in the vertical direction of the number of pixels, the unit is our common px,1px=1 pixels, our phones are usually in vertical pixels * cross-drawn pixels, such as 1920*1080,

3, screen pixel density: refers to a single size (per inch) pixel points, in dpi (dot per inch), pixel density and screen size and resolution,

4,DP and DIP:DP are density independent pixels abbreviations, which are pixels independent of screen density, with 160dpi as the benchmark, 1dip=1px,

5,SP: is the abbreviation for scale independent pixels, which is a unit of pixels that can be scaled according to the text size preference, typically set with font size, which is also recommended by Google,

6, when we develop the app, the official recommended font size is: 12SP,14SP,18SP,22SP, the use of odd-size font is not recommended.

In addition we have several picture folder differences in the project:

Name Pixel density Range

DRAWABLE-MDPI 120dpi-160dpi

DRAWABLE-HDPI 160dpi-240dpi

DRAWABLE-XHDPI 240dpi-320dpi

DRAWABLE-XXHDPI 320dpi-400dpi

Now also appears the xxxhdpi screen, corresponding pixel range 400dpi-480dpi

Screen Adaptation Solutions:

  • support for various screen sizes such as: 480*800,720*1280,480*854,1080*1920, etc.
      • layout using WRAP_ Content, match_parent or weight
      • Use relative layout instead of absolute layout
      • Depending on the screen size of the phone set different layout
      • using qualifiers ( using layout aliases, minimum width qualifier, dimension Qualifier, screen orientation qualifier, moving stretched bitmap (. 9) )
  • supports various screen densities
    • Using non-density-restricted pixels (DP)
    • provide alternate bitmap (. 9 figure)
  • Implement an adaptive user interface process
    • Determining the current layout
    • Respond to current layout
    • Reusing clips from other activities
    • Handling Screen configuration changes


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Android Learning Note: App screen adaptation related

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.