Android 2.x uses the theme 4. x and Android 2.x4.x.

Source: Internet
Author: User

Android 2.x uses the theme 4. x and Android 2.x4.x.

Currently, most Android Developers use Android APP 2. x SDK version, to be compatible with 2. x's mobile phone is understandable, but the biggest headache is 2. the theme of Version x is too ugly. This is what Android just took into account when it was launched, but it didn't take into account the appearance. Now, the operating system and the application software all use beautiful interfaces, the premise of a comfortable operation experience is whether it can be compatible. 2. x and 4. what is the theme style of x? Of course the answer is yes!

Sometimes, when installing an APP, we can see that the minimum supported versions are 2.1, 2.2, and so on, but the main style of opening the APP is indeed 4. we may think this way, since 2.1 and 2.2 are supported, the SDK version should be 2.x, but why is the theme style true? 4. what about x? The principle is very simple, since it is 4. the theme style of x must be 4. the SDK version of x is compiled. To achieve this effect, you can dynamically judge the current system version in the Code. if the version is earlier than 11, 2 is used. if the theme style of x is above 11, use 4. the theme style of x. You can create a BaseActivity and put the judgment code into it. All other activities inherit the BaseActivity. The main code is as follows:

If (Build. VERSION. SDK_INT <Build. VERSION_CODES.HONEYCOMB) {setTheme (android. r. style. theme_Black_NoTitleBar);} else {setTheme (android. r. style. theme_Holo_Light);} requestWindowFeature (Window. FEATURE_NO_TITLE); // remove the title bar.
This section of code is placed in the onCreate method, and super. onCreate (savedInstanceState); previously, the minimum supported version is declared in the AndroidManifest. xml file, which is generally 7 or 8:

<uses-sdk android:minSdkVersion="7" />
Finally, when using this method, some users will see a black page with a title bar as soon as they open the APP, so that they can see it first in AndroidManifest. define a default topic in xml:

android:theme="@android:style/Theme.Black.NoTitleBar" 

After that, we don't have to use the 2.x SDK to compile the project.

Note that if the project uses TabActivity, you must use the same method in your TabMainActivity.




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.