(24) Basic concept of screen adaptation

Source: Internet
Author: User

1.
Screen size: The size of the physical screen, looking at the diagonal of the screen.
Resolution: is actually the sum of the pixels. 1280*720
DPI: Density. (the pixels shown per inch)
2.
HDPI: Put 480*800 resolution of the picture ~240dpi
ldpi:320*240 ~120dpi
mdpi:320*480 ~160dpi (referential)
xhdpi:1280*720 ~320dpi

LDPI, MDPI, hdpi, xhdpi scaling
L:m: h:x
3:4:6:8

3.

480*800: Small resolution to large resolution compatible, when filling the screen, will stretch, appear blurry phenomenon, do not fill, do not stretch.
Large resolution is compatible with small resolution, and a program crash may occur. General Cetucci hdpi (picture with 480*800 resolution), only those pictures that fill the screen are cut a set of
(1280*720) is placed in the xhdpi file. In the Android design process, in order to adapt to different phone resolutions, most of the images need to be stretched or compressed, so there can be arbitrarily adjusted
The size of a picture format ". 9.png". This image is a special image format for Android development, and the advantage is that it can be used in a simple way to make a picture of which areas can be
Stretching, which areas can not be stretched to set, but also to display the location of the area is clearly marked.

4, the screen adaptation method:

4.1. Define different layout files according to the different resolutions of the screen, as shown in:

4.2, according to different resolutions of the screen definition of different sizes, as shown:

4.3, in the code according to the size of the screen, dynamic settings layout

// Get high screen width New    = =//Dynamic change of layout linearlayout production_factory = = = WINDOWSHEIGHT/2;p roduction_factory.setlayoutparams (params);

4.4 Use the attribute layout_weight to set.

(24) Basic concepts of screen adaptation

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.