Android-Skin-Loader icon indicating copy to clipboard operation
Android-Skin-Loader copied to clipboard

Layout中的一些View 不支持skin:enable="true"的设置?如果确实如此的话这个坑有点大呀

Open LoveLin0516 opened this issue 7 years ago • 1 comments

在布局中给FrameLayout android.support.design.widget.CollapsingToolbarLayout 等组件添加skin:enable="true"时是无效的,无法起到动态换肤的作用。因为SkinInflaterFactory中的

  private View createView(Context context, String name, AttributeSet attrs) {
	View view = null;
	try {
		if (-1 == name.indexOf('.')){
			if ("View".equals(name)) {
				view = LayoutInflater.from(context).createView(name, "android.view.", attrs);
			} 
			if (view == null) {
				view = LayoutInflater.from(context).createView(name, "android.widget.", attrs);
			} 
			if (view == null) {
				view = LayoutInflater.from(context).createView(name, "android.webkit.", attrs);
			} 
		}else {
            view = LayoutInflater.from(context).createView(name, null, attrs);
        }
            L.i("about to create " + name);
        } catch (Exception e) { 
		L.e("error while create 【" + name + "】 : " + e.getMessage());
		view = null;
	}
	return view;
}

这两种view FrameLayout 和android.support.design.widget.CollapsingToolbarLayout 在执行这个方法时会跑出异常最后返回空return null,后面也就不会再读取属性信息了,整个换肤的设置也就无效了。 目前测试的是这两个view,但不排除还有其他View也不支持,这样的话,这个坑就很大了

LoveLin0516 avatar Sep 08 '17 09:09 LoveLin0516

@LoveLin0516 我试了下,是可以的哦,createView也不是返回null哦

Charbing avatar Jan 23 '18 06:01 Charbing