"Reprint" summarize the correct gameplay of the theme (Theme) in Android

Source: Internet
Author: User

Http://www.cnblogs.com/zhouyou96/p/5323138.html

Summarize the correct gameplay for Android themes (Theme)

In the Androidmanifest.xml file there is <application android:theme= "@style/apptheme", where @style/apptheme is the reference res/values/ The theme style in Styles.xml is also possible to refer to the Res/values-v11/styles.xml or res/values-v14/ Styles.xml, this is based on the mobile phone system running this program to determine, if the phone system API version is more than 11 is v11/styles.xml, and so on. In values/ Styles.xml you will find Apptheme theme style is inherited from Appbasetheme, and Appbasetheme's parent topic is different, you can also from this location to modify the theme, this article is mainly to discuss how to modify this topic.

It is important to note that as a beginner or a specialized topic (Theme), you'd better remove values-v11 and values-v14 and values-vxx to avoid being disturbed by these things.

There are three sources of themes:

1) from the Android system comes with

2) from the compatible package (e.g. V7 Compatibility Pack)

3) You write a theme yourself

Here the main discussion of the former two, their own writing topic is not explored.

Use the theme that comes with your Android system to add "Android:", such as: Android:Theme.Black
Use the V7 Compatibility Pack for topics that do not require a prefix, directly: Theme.appcompat

Automatically prompts you when you write a theme in Android studio, but doesn't automatically prompt you in eclipse


The solution is not to write "Android:Theme.Black", but to write "@android: Style/theme.black" So there will be hints
Do not write "Theme.appcompat", but write "@style/theme.appcompat"

Because style (@android: Style/theme.black) and Theme (Android:Theme.Black) are still different in their mission, you can write "@android when writing in Eclipse in order to appear automatically: Style/theme.black ", but after finishing, remember to manually change to" Android:Theme.Black "

Now look at some of the themes

The system comes with a theme:
API 1:
Android:theme Root Theme
Android:Theme.Black Black Background
Android:Theme.Light White background
Android:Theme.Wallpaper with desktop wallpaper as background
Android:Theme.Translucent Transparent Background
Android:Theme.Panel tablet style
Android:Theme.Dialog dialog box style

API 11:
Android:Theme.Holo Holo Root Theme
Android:Theme.Holo.Black Holo Black Theme
Android:Theme.Holo.Light Holo White Theme

API 14:
Theme.devicedefault Device Default Root theme
Theme.DeviceDefault.Black Device Default Black theme
Theme.DeviceDefault.Light Device Default White theme

API 21: (online often said Android Material Design is to use this theme)
Theme.material Material Root Theme
Theme.Material.Light Material White Theme


Topics in the Compatibility Pack V7:
Root theme for THEME.APPCOMPAT compatibility topics
Theme.AppCompat.Black Black theme for compatible themes
Theme.AppCompat.Light White themes for compatible themes

Theme.appcompat theme is compatible theme, what does it mean?

This means that if the phone API that runs the program is 21, it is equivalent to the material theme, if the phone API that runs the program is 11, it is equivalent to the Holo theme, and so on

Compatibility Pack V7 will be continuously upgraded by Google Inc.:
For example, appcompat-v7-21.0 indicates an upgrade to API 21 compatibility
For example, appcompat-v7-23.2 indicates an upgrade to API 23 compatibility


In Eclipse, you can only see the version number of the APPCOMPAT_V7 followed by the API, how to identify it?
You can expand the Res folder of the V7 project in eclipse to see if there are folders values-21, values-23, and the maximum number is the API version number.


So the same is the V7 compatibility package, there will be different API version number differences, be aware.

All the themes that can be applied to the application are "Theme." Beginning
Not with "Theme." Instead of the application theme, it is used for some local controls
For example "Themeoverlay" theme, can be used for Toolbar control, here do not do in-depth analysis.
For example, "textappearance" theme, can be used to set the text appearance, here do not do in-depth analysis.
For example, there are many topics that start with "Base" in V7, which are parent topics that are not recommended for direct use.


More topics:
The following refers to " include ", for example, "Dialog" means dialog box style
such as Theme.dialog, Theme.Holo.Dialog, Theme.Material.Dialog, Theme.AppCompat.Dialog are all dialog-box style
Specifically there is no such combination, you are in the " automatic prompt " to see it, the hint is there, there is no.

Black noir Style
Light bright Style
Dark Dark Style
Daynight Daylight Style
Wallpaper Wallpaper for background
Translucent Transparent Background
Panel tablet style
Dialog dialog box style
Notitlebar no titlebar.
Noactionbar no Actionbar.
Fullscreen full Screen style
MinWidth dialog box or Actionbar width varies by content, not full screen
Whenlarge dialog Box Full screen
Translucentdecor Translucent Style
Nodisplay not showing, that is, hiding the
Withactionbar show Actionbar on Legacy themes

Many of the topics will be used in error, for many reasons, such as the form must inherit appcompactactivity, or to inherit the actionbaractiivty, or to inherit fragmentactivity, or to manually specify the width of the height, Or you need to upgrade the minimum API version, or you need a later version of the SDK, or the compatibility package version is not the reason.

Hard to toss it!!!

Do not write well, please criticize correct.

"Reprint" summarize the correct gameplay of the theme (Theme) in Android

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.