Skip to content

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

@LoveLin0516

Description

@LoveLin0516

在布局中给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也不支持,这样的话,这个坑就很大了

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions