在这个示例Material Design Owl app design之后,有黄色主题的个性化屏幕,蓝色主题的浏览屏幕和深色主题的学习屏幕,如下所示:

我的问题是,我应该为选定的屏幕实现3个活动吗?或者我应该为每个片段实现不同的主题?
我更喜欢一个带有jetpack导航的活动,但是可以为特定的片段设置主题吗?
发布于 2019-09-08 18:30:28
在清单中设置主题通常用于活动。
如果您想为片段设置主题,请在片段的onCreateView()中添加下一段代码:
@Override
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);
}这将使用Activity中的经典片段进行处理。
https://stackoverflow.com/questions/57840917
复制相似问题