Forward Http://stormzhang.com/android/2015/03/29/android-support-library/?utm_source=tuicool 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.
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,pagetabatrip,loader, Fileprovider, etc.
Gradle Reference Method:
compile ‘com.android.support:support-v4:21.0.3‘
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‘
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.
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 4.0 design style, but in order to let 4.0 before the version can also have this style how to do? 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, so at present, I personally recommend not to consider compatibility.
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.DarkActionBar is to correspond to compatible material design theme.
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 ' 21 represents the Compatibility Pack for API level 21, so if you are referencing a version prior to 21, the default Theme.AppCompat.Light is holo style, the version starting from 21 is material style by default
* * 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 Android Support Compatibility Pack is detailed