Android Default Theme
Solution 1:
The default theme varies depending on the API level (to be consistent with the general UI).
On API < 10, the theme was a set of styles (as in the link below) known as Theme
, above that API 10, the default theme was Theme_Holo
and now, starting with API 21, the default theme has become Theme.Material
.
- API < 10: see the frameworks's code
Theme
orTheme.AppCompat
- 10 >= API < 21: read the Styles and Themes guide
Holo_Theme
orTheme.AppCompat
- API >= 21 Using the Material Theme guide
Theme.Material
Most of those styles are available through the android.support
libraries.
PS: AFAIK the light theme has always been the default one.
Solution 2:
It is best to define a default theme yourself instead of relying on android to pick the default theme. This is because different versions of android may have completely different default themes, and could mess up your layouts.
You can declare a theme for your application in AndroidManifest.xml
<applicationandroid:theme="@style/MyTheme".....>
Then in res/values
folder, you edit/add a file themes.xml
and add something like the following:
<?xml version="1.0" encoding="utf-8"?><resourcesxmlns:android="http://schemas.android.com/apk/res/android"><stylename="MyTheme"parent="@android:style/Theme.Holo">
... customize your theme here
</style></resources>
You can edit the parent
of your theme to anything you want...
You can also use @android:style/Theme.Holo
directly in AndroidManifest.xml
if you do not want any customization at all.
Use Theme.AppCompat.Holo
if API version below 11
Solution 3:
The default theme for App is implement in Resources.java!
/**
* Returns the most appropriate default theme for the specified target SDK version.
* <ul>
* <li>Below API 11: Gingerbread
* <li>APIs 11 thru 14: Holo
* <li>APIs 14 thru XX: Device default dark
* <li>API XX and above: Device default light with dark action bar
* </ul>
*
* @param curTheme The current theme, or 0 if not specified.
* @param targetSdkVersion The target SDK version.
* @return A theme resource identifier
* @hide
*/publicstaticint selectDefaultTheme(int curTheme, int targetSdkVersion) {
return selectSystemTheme(curTheme, targetSdkVersion,
com.android.internal.R.style.Theme,
com.android.internal.R.style.Theme_Holo,
com.android.internal.R.style.Theme_DeviceDefault,
com.android.internal.R.style.Theme_DeviceDefault_Light_DarkActionBar);
}
/** @hide */publicstaticint selectSystemTheme(int curTheme, int targetSdkVersion, int orig, int holo,
int dark, int deviceDefault) {
if (curTheme != 0) {
return curTheme;
}
if (targetSdkVersion < Build.VERSION_CODES.HONEYCOMB) {
return orig;
}
if (targetSdkVersion < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
return holo;
}
if (targetSdkVersion < Build.VERSION_CODES.CUR_DEVELOPMENT) {
return dark;
}
return deviceDefault;
}
It varies depending on the API level, so you'd better to define your own AppTheme in AndroidManifest.xml to assure Theme in all API level devices.
Pls refer previous answer.
Post a Comment for "Android Default Theme"