Turn: Android Support Compatibility Pack

Source: Internet
Author: User

This article goes from Stormzhang's Android support Compatibility Pack

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:

' 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:

' 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 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. The corresponding program implementation on the Theme.Material.Light, Theme.Material.Light.DarkActionBar, etc., but this style can only be used in the 5.0 version of the phone, if the application before 5.0 Material Design how to do it? The same reference APPCOMPAT-V7 package, this time the Theme.AppCompat.Light, Theme.AppCompat.Light.DarkActionBar is the relative should be 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 referring to a version prior to 21, By default these Theme.AppCompat.Light are 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.google.cn/topic/libraries/support-library/features.html

Turn: Android Support Compatibility Pack

Related Article

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.