gpt4 book ai didi

java - Android 如何解释布局中的@null 关键字?

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

我通过寻找系统如何识别布局中提到的 @null 关键字的答案来挖掘 Android 的来源。例如,

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@null"
android:layout_width="match_parent"
android:layout_height="match_parent"/>

到目前为止,我遵循了这条路线:

  1. TypedArray#getDrawable(int index)
  2. ResourcesImpl#getValue(@AnyRes int id, TypedValue outValue, boolean resolveRefs)
  3. AssetManager#getResourceValue(@AnyRes int resId, int densityDpi, @NonNull TypedValue outValue,boolean resolveRefs)
  4. AssetManager#loadResourceValue(int ident, short density, TypedValue outValue,boolean resolve)

我试图在 source code 中找到AssetManager loadResourceValue 方法的 JNI 实现,但我没有成功。

如果有人能指出 Android 如何解析 @null 标签,我将不胜感激。

提前致谢!

最佳答案

您正在搜索通过 NDK 公开的 AssetManager 前端。根本没有 JNI 函数。 android.util.AssetManager 的 JNI 包装器是 here .

ResTable 类用于实际的解析和解析。如果你深入挖掘 - 你会发现 lines处理 @null 的地方。

关于java - Android 如何解释布局中的@null 关键字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39590545/

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