2016-09-20 13 views
7

Tôi đang tìm hiểu nguồn Android bằng cách tìm kiếm câu trả lời về cách hệ thống nhận ra @null từ khóa được đề cập trong bố cục. Ví dụ,Cách Android diễn giải @null từ khóa trong bố cục?

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

đến nay tôi đi theo con đường này:

  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)

Tôi cố gắng để f ind in source code thực hiện JNI của AssetManager phương thức loadResourceValue, nhưng tôi chưa thành công.

Tôi sẽ đánh giá cao nếu có ai có thể chỉ ra cách Android giải quyết thẻ @null.

Cảm ơn trước!

Trả lời

1

Bạn đang tìm kiếm trong AssetManager giao diện người dùng được hiển thị qua NDK. Không có chức năng JNI nào cả. Trình bao bọc JNI cho android.util.AssetManagerhere.

ResTable lớp được sử dụng để phân tích cú pháp và phân tích thực tế. Nếu bạn đào sâu hơn một chút - bạn có thể tìm thấy lines nơi xử lý @null.

+0

Ồ, mã có vẻ điên rồ! Serio, cảm ơn bạn đã trả lời! –

Các vấn đề liên quan