首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将主题设置为片段

将主题设置为片段
EN

Stack Overflow用户
提问于 2016-06-07 15:08:54
回答 1查看 3.4K关注 0票数 0

如何为片段设置主题?

下面的代码对我不起作用,或者我哪里错了?

代码语言:javascript
复制
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {  

    // create ContextThemeWrapper from the original Activity Context with the custom theme  
    final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.yourCustomTheme);  

    // clone the inflater using the ContextThemeWrapper  
    LayoutInflater localInflater = inflater.cloneInContext(contextThemeWrapper);  

    // inflate the layout using the cloned inflater, not default inflater  
    return localInflater.inflate(R.layout.yourLayout, container, false);  
} 
EN

回答 1

Stack Overflow用户

发布于 2017-07-13 22:00:30

上面的代码将更改片段布局中小部件的主题,但不会更改ActionBar和状态栏的主题。

向您的片段布局添加一个SeekBar和一个开关,可以看到它的主题是否已更改。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37672676

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档