This article mainly introduces the support compatibility package in the Android SDK in detail, this article distinguishes between the version differences of Support Library, the concept of various theme and usage precautions, etc., the need of friends can refer to the following
Background
A question from the answer to the invitation answered Android AppCompat and holo a question? , it seems that many people still do not understand these compatibility pack, then simply write a blog it.
Support Library
We all know that some Android SDK is split, so Google officially provides the Android support Library packages package to ensure the compatibility of the development of high-version SDK, so you may often see v4,v7,v13 these numbers,
First we'll figure out what these numbers mean, and the difference between them.
Support-v4
Used on API Lever 4 (i.e. Android 1.6) or later. It contains relatively more content and is used more broadly, for example: Fragment,notificationcompat,loadbroadcastmanager,
Viewpager,pagetabstrip,loader,fileprovider, etc.
Gradle Reference Method:
Compile ' com.android.support:support-v4:21.0.3 '
Support-v7
This package was designed to consider API Level 7 (i.e. Android 2.1) and above, but V7 relies on V4 for this package, V7 supports action bar and some theme compatibility.
Gradle Reference Method:
Compile ' com.android.support:appcompat-v7:21.0.3 '
Support-v13
This package is designed for API level 13 (ie Android 3.2) and later, generally we are not used, tablet development can be used, here is not too much to introduce.
Theme
Returning to this question, let us introduce the concepts of various theme.
Hoho Theme
Before 4.0 Android can be said to be no design, after 4.0 launched the Android design, since then the Android has a great improvement, and in the program implementation of the corresponding is the holo style, so you see there are similar Theme.Holo.Light,
Theme.Holo.Light.DarkActionBar is a 4.0 design style, but what can I do to make this style available in the previous version of the 4.0? This time will have to quote V7 package, so corresponding to have Theme.AppCompat.Light,
Theme.AppCompat.Light.DarkActionBar, if your program minimum supported version is 4.0, then you can not consider the compatibility of v7.
Material Design Theme
This year's 5.0 release, Android introduced the concept of material design, which is another big breakthrough in designing Android. corresponding to the implementation of the program has Theme.Material.Light, Theme.Material.Light.DarkActionBar and so on,
But this style can only be used in the 5.0 version of the phone, if you apply material design before 5.0 how to do? The same reference APPCOMPAT-V7 package, this time of Theme.AppCompat.Light, Theme.AppCompat.Light.DarkActionBa
R is the theme of the material design that is relatively compatible.
Precautions
Gradle Reference APPCOMPAT-V7 Package when you do not need to reference V4, because V7 default contains v4 package; compile ' com.android.support:appcompat-v7:21.0.3 ' in 21 for API level 21 release of the Compatibility Pack,
So if you're referring to a version prior to 21, these Theme.AppCompat.Light are holo-style, and the default version from 21 is material style.
After using AppCompat, all your activity should inherit from Actionbaractivity, and actionbaractivity inherit from fragmentactivity, so use fragment with ease;
Finally, I believe that has been told very clearly, we have questions can be directly blog comments. If the English is good, can directly to the official most authoritative explanation https://developer.android.com/tools/support-library/features.html
The support Compatibility Pack in the Android SDK is detailed