Now, And most Android developers use the SDK version of 2.x when they develop the Android app. In order to be compatible with 2.x mobile phone this is understandable, but the most troubling is the 2.x version of the theme is in too ugly, this is the launch of Android just consider the practical, and did not take into account the aesthetics, and now up to the operating system to the application software is a beautiful interface, Comfortable operation experience as the premise, then whether it can be compatible with 2.x and can use the theme of 4.x style it? The answer, of course, is there!
Sometimes when we install an app, we will see that support the minimum version for 2.1,2.2, etc., but open the app its main style is really 4.x, we may think so, since it can support 2.1,2.2 that it uses the SDK version should be 2.x, but why the theme style is really 4.x? The truth is simple, Since is the theme of the 4.x style, it must be compiled with the SDK version of 4.x, in order to achieve this effect, you can dynamically judge the current version of the system in the code, if you use the 2.x theme style below 11, if more than 11 is using 4.x theme style, you can create a baseactivity, judge the code into Among them, the other activity all inherit 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
The code is placed in the OnCreate method, Super.oncreate (Savedinstancestate) before, and the minimum supported version is declared in the Androidmanifest.xml file, typically 7, or 8:
<USES-SDK android:minsdkversion= "7"/>
Finally, some students after using this method, open the app for a moment will see a black interface with the title bar a flash, so that you can first ina default theme can be defined in Androidmanifest.xml:
After that, we can no longer use the 2.x SDK to compile the project.
It is also important to note that if the project uses tabactivity, it needs to be judged in the same way in your tabmainactivity.
Android 2.x version uses the theme of 4.x