在我的应用程序中,我有单个活动和所有其他片段
我正在设置style.xml的活动背景,如下所示
- <item name="android:windowBackground">@color/very_light_gray</item>
现在只有一个特定的片段我想设置背景透明,我无法做到尝试下面的片段代码片段对我来说不起作用
- @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);
- }
知道怎么做吗?