如何Android的支持库工作? [英] How Android Support Library work?

查看:123
本文介绍了如何Android的支持库工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,支持库在使用,因为旧的设备没有新的API。例如,他们不知道什么片段,以及如何实现它。因此,这些行为是在支持库定义的。

As far as I know, support library is using because old devices don't have new APIs. For example they don't know what Fragment is and how to implement it. Therefore, these behaviors are defined in support library.

所以,我的主要问题是,什么是片段库之间的/有差别(S)与它的孪生兄弟的支持库,在API 11(的Andr​​oid 3.0,蜂窝)出台。

So, my main question is, what is/are difference(s) between library of Fragment in support library with its twin which is introduced in API 11 (Android v3.0, Honeycomb).

我的第二个问题是,如果它有可能把每一个新的API支持库,为什么我们有两种类型的图书馆?我的意思是机器人可以释放刚下支持库,所有的API,而不是支持库和Android版本X.XX库。

My second question is, If its possible to put every new API in support library, why we have two types of libraries? I mean Android can release all APIs just under support library rather than support library and Android version X.xx library.

推荐答案

据我的理解,支持库可以正常工作内置的API的选择,但他们不应该,因为它们直接影响的大小应用程序。

As far as I understood, support libraries may work as alternative of built-in APIs, but they are not supposed to be, because they directly effect the size of the application.

例如,一个支持库为2MB,并使用其功能,它需要所有的类,资源等(2MB的),所以现在 classes.dex (所有类的Dalvik可执行文件中的应用程序正在使用)我的应用程序还包括支持库类,以及相同的资源。因此,如果没有支持库我的应用程序大小为1MB,那么现在与支持库的大小为2MB多余的,这意味着3MB总和。

For example, a support library is of 2MB, and to use its functionality, it takes all classes, resources, etc (of 2MB), so now classes.dex (Dalvik executable file of all classes being used in application) of my application also include that support library classes, and same for resources. So, if without support library my app size was 1MB, then now with support library the size is 2MB extra, which means 3MB total.

现在,假设此支持库功能是如此普遍,在单个设备中,如果我有10个应用程序,那么至少9也是使用同样的支持库,所以9 * 2 = 18MB我的设备上所使用的相同支持库,这是用在了所有的应用程序,这是不好的,因为现在的18MB可能没那么多,但所需的空间可以提高,如果你有使用支持库更多的应用程序。

Now, suppose this support library feature is so common that on single device, if I have 10 apps, then at least 9 are using this same support library, so 9*2 = 18MB on my device is being used by the same support library, which is repeated in every application, which is bad, because for now 18MB might not be so much, but the space required can increase, if you have more applications using that support library.

因此​​,最好的选择是有2MB支持库已经在您的操作系统为任意数量的应用程序,而不必是为每个应用程序。因此,支持库,目的是要使用时,你真的想在你的应用程序的一些有效的功能,以支持旧版本。

Thus, the best option is to have that 2MB support library already in your OS for any number of apps, instead of having it for each application. So, support libraries are meant to be used when you really want some efficient features in your app to support older versions.

另一个问题出现在这里:

Another question arise here:

为什么不这样支持库添加到操作系统作为自己的更新,因此,如果没有大小问题每一个应用程序都可以访问该功能?

why not this support library is added to the OS as its own update, so that every app without size problems can access that functionality?

答案是,有可能是一个很大的错误。假设一些用户不具有该更新(支持库)安装...

The answer is that there could be a lot of errors. Suppose some user doesn't have that update (support library) installed...

也有机会,作为更新,也可以不作为应该是工作作为高效,或可能导致问题,而与OS结合,因为我们已经看到,每个OS(窗口,在Linux,Mac)自带新的版本,而不是只给生命一次更新所有新功能。

There is also the chance that as an update, it may not work as efficient as supposed to be, or may cause problems while integrating with the OS, as we already seen that each OS (windows, Linux, mac) comes with new versions, instead of just giving updates for life time for all new features.

这篇关于如何Android的支持库工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆