Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Android为片段设置透明背景大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
在我的应用程序中,我有单个活动和所有其他片段

我正在设置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);
}

知道怎么做吗?

解决方法

interface OnFragmentDisplay{
  onFragmentDisplay();
}

当此片段显示更新活动背景为透明..或在活动中将其设置为主题

this linkthis可能有所帮助

你试过这个吗?

fragment.getView().setBACkgroundColor(Color.WHITE);

大佬总结

以上是大佬教程为你收集整理的Android为片段设置透明背景全部内容,希望文章能够帮你解决Android为片段设置透明背景所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。