gpt4 book ai didi

android - android 是否总是使用最新的 API 来运行应用程序?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:03:36 25 4
gpt4 key购买 nike

我在搞乱 MeasureSpec当我遇到这段文字时:

Note: On API level 17 and lower, makeMeasureSpec's implementation was such that the order of arguments did not matter and overflow in either value could impact the resulting MeasureSpec. RelativeLayout was affected by this bug. Apps targeting API levels greater than 17 will get the fixed, more strict behavior.

所以这让我想知道:如果我为 API 14 构建了一个应用程序,但我在 API 22 设备上运行它,它会修复错误还是

最佳答案

makeMeasureSpec (API 17<) 方法的实现如下:

 public static int makeMeasureSpec(int size, int mode) {
if (sUseBrokenMakeMeasureSpec) {
return size + mode;
} else {
return (size & ~MODE_MASK) | (mode & MODE_MASK);
}
}

如您所见,它的返回值取决于 sUseBrokenMakeMeasureSpec 的值 value is assignedView 类的构造函数中:

  sUseBrokenMakeMeasureSpec = targetSdkVersion <= JELLY_BEAN_MR1;

因此只有应用的目标才能决定行为。通过这种方式,较新的系统可以保持与旧应用程序的兼容性,从而消除旧的行为。

关于android - android 是否总是使用最新的 API 来运行应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34424317/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com