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

Tom*_*tel 7 java android

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:background="@null"
          android:layout_width="match_parent"
          android:layout_height="match_parent"/>
Run Code Online (Sandbox Code Playgroud)

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

  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)

我试图找到源代码 JNI实现的AssetManager loadResourceValue方法,但我还没有成功.

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

提前致谢!

Ser*_*gio 1

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

ResTable类用于实际的解析和解析。如果你挖得更深一点 - 你可以找到处理过的线@null