Android <supports-sceeens> usage, adapts to screen size

Source: Internet
Author: User

As we all know, when the Android 2.3 (Gingerbread) SDK was released, a third-party add-ons was added to the SDK, including the Galaxy Tab Addon for tablets.

When we launch a new tablet simulator, first we need to set the "scale display to real size" option, which will allow the tablet screen size to match the size of our computer screen. Take My computer as an example, my screen size is 1440x900px.


If we run an example of SDK 1.6 on our tablet simulator (we need at least API level 4, SDK 1.6 for tablets), you will see the following:

Our application does not fill the screen of the entire tablet emulator, and we will solve the problem below.

First open the Androidmanifest.xml file and add the following code:

<manifest xmlns:android= "Http://schemas.android.com/apk/res/android"
Package= "Com.niuren.test.main"
Android:versioncode= "5"
Android:versionname= "1.3.1" >

<supports-screens
Android:smallscreens= "true"
Android:normalscreens= "true"
Android:largescreens= "true"
Android:anydensity= "true"
/>

Now our program is filled with the entire screen, as shown in:

As with developing applications for tablets and developing applications for mobile phones, we need to create two resource file directories in the/res directory, create Drawable-large and Layout-large directories, and put all the picture resources and UI files inside. Of course, you will also need to create a Layout-large-land directory for the Flat screen tablet program. The entire application structure looks like this:

Android <supports-sceeens> usage, adapts to screen size

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.