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

xml布局中使用include、ViewStub对换肤的影响 #8

Open
fengshenzhu opened this issue Feb 18, 2016 · 4 comments
Open

xml布局中使用include、ViewStub对换肤的影响 #8

fengshenzhu opened this issue Feb 18, 2016 · 4 comments

Comments

@fengshenzhu
Copy link
Owner

No description provided.

@fengshenzhu fengshenzhu changed the title include viewstub对换肤的影响 xml布局中使用include、viewstub对换肤的影响 Mar 2, 2016
@fengshenzhu
Copy link
Owner Author

include可行,ViewStub不支持

@fengshenzhu fengshenzhu changed the title xml布局中使用include、viewstub对换肤的影响 xml布局中使用include、ViewStub对换肤的影响 Mar 2, 2016
@fengshenzhu
Copy link
Owner Author

添加ViewStub换肤支持,需手动设置ViewStub的LayoutInflater:

stub.setLayoutInflater(inflater);

根据ViewStub是否在Fragment中,inflater传值为Fragment/Activity的有效LayoutInflater(见 #3 )。

原理见LayoutInflater.createView():

if (view instanceof ViewStub) {
    // Use the same context when inflating ViewStub later.
    final ViewStub viewStub = (ViewStub) view;
    viewStub.setLayoutInflater(cloneInContext((Context) args[0]));
}

@fengshenzhu
Copy link
Owner Author

上述操作(stub.setLayoutInflater(inflater))已放在库里执行,应用程序可不调整。

@fengshenzhu
Copy link
Owner Author

ViewStub.setLayoutInflater(LayoutInflater)需要API 16才支持,低版本暂不支持ViewStub的换肤。

@fengshenzhu fengshenzhu added Attention and removed TODO labels Mar 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant