Example of automatically adapting to screen resolution on the android Interface

Source: Internet
Author: User

 

Create an interface for mobile phones with different resolutions

1. First, go to the res folder.

2, create a folder named layout-1024x768,

Among them, 1024x768 is the screen resolution size. It is worth noting that the large numbers in the resolution must be written before, no

A syntax error occurs. Such as layout-768x1024 is wrong.

3. Compile main. xml:

<? Xml version = "1.0" encoding = "UTF-8"?>

<LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android"

Android: orientation = "vertical" android: layout_width = "fill_parent"

Android: layout_height = "fill_parent">

<TextView android: layout_width = "fill_parent"

Android: layout_height = "wrap_content" android: text = "@ string/hello"/>

<TextView android: layout_width = "fill_parent" android: id = "@ + id/TV"

Android: layout_height = "wrap_content" android: text = "1024x768"/>

</LinearLayout>

4. Directly copy main. xml in the folder where the layout-1280x800 resolution is created as described above.

5. Create the 1024x768 and 1280x800 simulators respectively:

6. Add <supports-screens android: largeScreens = "true" to AndroidManifest. xml"

Android: anyDensity = "true"/> otherwise, your application will not be in full screen.

For more information, see the example helloword.

7. layout by default. Do not delete it. If the specified resolution does not exist, layout will be called by default. If yes, an error is returned.

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.