The Android Support Compatibility Pack is detailed

Source: Internet
Author: User

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 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 the minimum supported version of your program is 4.0, you can not consider V7 compatibility.

    • 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.DarkActionBar 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 contains the default V4 package,

    • compile ' com.android.support:appcompat-v7:21.0.3 '   21 stands for API level 21 release of the compatibility Pack, so if you refer to a version prior to 21, the default of these Theme.AppCompat.Light is holo style, 21-based version by default is material style

    • Li style= "line-height:20px" >

      after using AppCompat, All your activity should inherit from Actionbaractivity, and actionbaractivity inherit from fragmentactivity, so use fragment safely;

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


Reprinted from: http://stormzhang.com/android/2015/03/29/android-support-library/Thanks for sharing!

The Android Support Compatibility Pack is detailed

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.