Android has a good user experience on different screen sizes

Source: Internet
Author: User

Let your app have a good user experience on different screen sizes, and you should create a unique XML layout file for each screen size you want to support. Each layout file should be stored in the appropriate resource directory, with the directory name suffix-<screen_size>. For example, the name of a layout directory that holds a large screen is res/layout-large/.

Tip: The Android system will automatically scale the layout to properly fit the screen. So you don't have to worry about the actual size of the UI elements you're designing for different layouts, you need to be aware of the layout structure that affects the user experience (for example, the size and location of the layout next to the important layout).

For example, this project includes a default layout directory and a layout directory for large screens: Myproject/res/layout/main.xml layout-large/ Main.xml

The filenames must be exactly the same, but their content is not the same, to provide the best UI presentation for different screen sizes.

Simply refer to the layout in your app: @Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.main); }

The system will add a layout file to the appropriate layout directory based on the device's screen size. For more information on choosing the appropriate layout resource, see Providing Resources guide.

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.