Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
LoveLin0516 opened this issue Sep 8, 2017 · 1 comment

Comments

@LoveLin0516
Copy link

LoveLin0516 commented Sep 8, 2017

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

@Charbing
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants