我目前正在项目中使用“导航组件”,使用“单一活动”方法。我的每个片段都有透明的状态栏和不同的windowBackground。我正在寻找一种方法来更改片段windowBackground,而不会影响其他片段。
我已经尝试过这里提到的解决方案:https://stackoverflow.com/a/15496425/11402079但它没有用。我找不到任何与此“单一活动”方法相关的内容。有人可以帮忙吗?
使用ContextThemeWrapper为fragment提供不同的主题。使用contextThemeWrapper时,你的minSDKVersion应该> = 11。
在片段的onCreateView方法中使用它
final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.yourCustomTheme);