简体   繁体   中英

Does the Android Support Library default to the native libraries on the latest Android Version?

When starting any Android project, a developer has to choose between using the support library or the native library.

What happens when the support library is used on Lollipop? If I use the ToolBar support library object , and it runs on a Lollipop device, does the library default to the native implementation of the Toolbar automatically?

I am assuming that the native library is more efficient than the support library.

EDIT: referring to Toolbar now as an example instead of RecyclerView

What happens when the support library is used on Lollipop? If I use the ToolBar support library object, and it runs on a Lollipop device, does the library default to the native implementation of the Toolbar automatically?

No, it does not, as you can tell by looking at the source code for the backported Toolbar . Nothing in the current appcompat-v7 artifact will delegate to a native implementation.

The Android Support Package is vast, and different things will behave differently. The best rule of thumb is for Java classes that end in Compat (eg, NotificationCompat ), the class will delegate to a native implementation where possible, based upon API level, and will either implement a backport or simply "no-op" the request where a native implementation does not exist. And, despite the name, AppCompat is not a Java class, which is why it still complies with this rule of thumb. :-)

I am assuming that the native library is more efficient than the support library.

Not for most definitions of the word "efficient". It will save APK size. In terms of speed and memory consumption, there is unlikely to be any significant difference.

When starting any Android project, a developer has to choose between using the support library or the native library.

As noted, the "support library" is vast, and apps may well use a mix of things in the Android Support Package and things that are not. For example, apps may use NotificationCompat (eg, to improve support for Android Wear and Android 5.0 lockscreen notifications) while using the native action bar and fragments.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM