Android official getting started documentation [10] supports different screens, android official

Source: Internet
Author: User

Android official getting started documentation [10] supports different screens, android official
Android official getting started documentation [10] supports Different screen Supporting Different Screens
Supports different screens

 

This lesson teaches you
1. Create Different Layouts
2. Create Different Bitmaps

You shoshould also read
• Designing for Multiple Screens
• Providing Resources
• Iconography design guide

This lesson teaches you
1. Create different la s
2. Create different bitmaps

You should also read
• Designed for multiple screens
• Provide resources
• Guidelines for imaging Design

Android categorizes device screens using two general properties: size and density. you shoshould have CT that your app will be installed on devices with screens that range in both size and density. as such, you shoshould include some alternative resources that optimize your app's appearance for different screen sizes and densities.
• There are four generalized sizes: small, normal, large, xlarge
• And four generalized densities: low (ldpi), medium (mdpi), high (hdpi), extra high (xhdpi)
Android uses two general properties for device screens: size and density. You should expect that your application will be installed with a screen, a range of devices in scale and density. Therefore, you should include some alternative resources that optimize the appearance of your application with different screen sizes and density.
• Four general dimensions: small, normal, large, and xlarge (small, normal, large, and super large)
• 4 broad density: low (ldpi), medium (mdpi), high (hdpi), and extremely high (xhdpi)

To declare different layouts and bitmaps you 'd like to use for different screens, you must place these alternative resources in separate directories, similar to how you do for different language strings.
Declare different la S and bitmaps. To use different screens, you must replace these resources in different directories, similar to how you make different language strings.

Also be aware that the screens orientation (landscape or portrait) is considered a variation of screen size, so many apps shoshould revise the layout to optimize the user experience in each orientation.
In addition, the screen direction (horizontal or vertical) is considered to be a change in the screen size, so many applications should modify the layout to optimize the user experience in each direction.

 

Create Different Layouts
Create different la s


--------------------------------------------------------------------------------

To optimize your user experience on different screen sizes, you shoshould create a unique layout XML file for each screen size you want to support. each layout shoshould be saved into the appropriate resources directory, named with a-<screen_size> suffix. for example, a unique layout for large screens shocould be saved under res/layout-large /.
To optimize the user experience in different screen sizes, you should create a unique layout XML file for each screen size to be supported. Each layout should be saved to the corresponding resource directory named-<screen_size> suffix. For example, res/layout-large/should exist in the unique layout of the large screen /.

Note: Android automatically scales your layout in order to properly fit the screen. thus, your layouts for different screen sizes don't need to worry about the absolute size of UI elements but instead focus on the layout structure that affects the user experience (such as the size or position of important views relative to sibling views ).
Note: Android automatically scales your layout to properly adapt to the screen. Therefore, you do not have to worry about the absolute size of the UI elements in different la S. Instead, you focus on the layout structure, which affects the user experience (such as the size or important opinion position relative to the same level ).

For example, this project has des a default layout and an alternative layout for large screens:
For example, this project includes a default layout and an alternative layout for large screens:

MyProject/
Res/
Layout/
Main. xml
Layout-large/
Main. xml

The file names must be exactly the same, but their contents are different in order to provide an optimized UI for the corresponding screen size.
The file names must be identical, but their contents are used to provide different user interfaces for corresponding screen size optimization.

Simply reference the layout file in your app as usual:
As usual, you can easily reference layout files in your applications:

@ Override
Protected void onCreate (Bundle savedInstanceState ){
Super. onCreate (savedInstanceState );
SetContentView (R. layout. main );
}

The system loads the layout file from the appropriate layout directory based on screen size of the device on which your app is running. more information about how Android selects the appropriate resource is available in the Providing Resources guide.
The system loads a directory layout File Based on the screen size of the device on which the application is running. For more information about how to select a proper resource for Android, see the resource guide.

As another example, here's a project with an alternative layout for landscape orientation:
For another example, here is a horizontal alternative layout project:

MyProject/
Res/
Layout/
Main. xml
Layout-land/
Main. xml

By default, the layout/main. xml file is used for portrait orientation.
By default, files in layout/main. xml are used vertically.

If you want to provide a special layout for landscape, including while on large screens, then you need to use both the large and land qualifier:
If you want a special layout for the landscape, including on the big screen at the same time, you need to use both the large and land delimiters:

MyProject/
Res/
Layout/# default (portrait)
Main. xml
Layout-land/# landscape
Main. xml
Layout-large/# large (portrait)
Main. xml
Layout-large-land/# large landscape
Main. xml

Note: Android 3.2 and above supports an advanced method of defining screen sizes that allows you to specify resources for screen sizes based on the minimum width and height in terms of density-independent pixels. this lesson does not cover this new technique. for more information, read Designing for Multiple Screens.
Note: Android 3.2 and later support advanced methods for defining screen sizes, which allow you to specify screen size resources based on the minimum width and height of density-independent pixels. This lesson does not cover this new technology. For more information, see the design of multiple screens.

Create Different Bitmaps
Create different bitmap


--------------------------------------------------------------------------------

You shoshould always provide bitmap resources that are properly scaled to each of the generalized density buckets: low, medium, high and extra-high density. this helps you achieve good graphical quality and performance on all screen densities.
You should always provide resources that are scaled appropriately to each generalized density bucket bitmap: low, medium, high, and ultra-high. This will help you achieve good image quality and performance on all screen density.

To generate these images, you should start with your raw resource in vector format and generate the images for each density using the following size scale:
• Xhdpi: 2.0
• Hdpi: 1.5
• Mdpi: 1.0 (baseline)
• Ldpi: 0.75
To generate these images, you should generate images of each density using the following dimensions from your original resources in vector format:
• Xhdpi: 2.0
• Hdpi: 1.5
• Mdpi: 1.0 (baseline)
• Ldpi: 0.75

This means that if you generate a 200x200 image for xhdpi devices, you shoshould generate the same resource in 150x150 for hdpi, 100x100 for mdpi, and 75x75 for ldpi devices.
This means that if you generate a 150x150 image xhdpi device, you should generate ldpi devices with the same resource in 100x100 hdpi, x mdpi and 75x75.

Then, place the files in the appropriate drawable resource directory:
Then, the files in the appropriate resource directory will be drawn:

MyProject/
Res/
Drawable-xhdpi/
Awesomeimage.png
Drawable-hdpi/
Awesomeimage.png
Drawable-mdpi/
Awesomeimage.png
Drawable-ldpi/
Awesomeimage.png

Any time you reference @ drawable/awesomeimage, the system selects the appropriate bitmap based on the screen's density.
When you reference @ drawable/awesomeimage, the system selects a bitmap based on the screen density.

Note: Low-density (ldpi) resources aren't always necessary. When you provide hdpi assets, the system scales them down by one half to properly fit ldpi screens.
Note: low-density (ldpi) resources are not always necessary. When you are directed to hdpi resources, the system scales down from half to the right ldpi screen.

For more tips and guidelines about creating icon assets for your app, see the Iconography design guide.
For more tips and guidance on the icon assets created for your application, see the imaging design guide.

Https://developer.android.com/training/basics/supporting-devices/screens.html

Related Article

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.