10.源码阅读(插件式换肤-安卓Resources加载资源的过程-android api 26)
我们知道,每一个View的子类都可以设置backgroud,那么这个背景是如何加载出来的呢? 找到View的构造方法 public View(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { ...... case com.android.internal.R.styleable.View_background: background = a.getDrawable(attr); break; ...... } @Nullable public Drawable getDrawable(@StyleableRes int index) { return getDrawableForDensity(index, 0); } @Nullable public Drawable getDrawableForDensity(@StyleableRes int index, int density) { ...... return mResources.loadDrawable(...