Java教程

短视频直播源码,DialogFragment全屏且半透明

本文主要是介绍短视频直播源码,DialogFragment全屏且半透明,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

短视频直播源码,DialogFragment全屏且半透明

DialogFragment基本使用:

 

TestDialogFragment dialogFragment = new TestDialogFragment();
dialogFragment.show(getSupportFragmentManager(), "test");

默认唤起的DialogFragment不全屏,四周有边距。可通过setStyle实现全屏且透明:

 

<style name="fragment_dialog" parent="@android:style/Theme.NoTitleBar.Fullscreen">
        <item name="android:windowCloseOnTouchOutside">true</item>
        <item name="android:windowFrame">@null</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowNoTitle">true</item>
        <item name="android:background">@android:color/transparent</item>
        <item name="android:windowBackground">@android:color/transparent</item>
</style>

 

在自定义DialogFragment的onCreate方法中setStyle:

 

@Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(STYLE_NO_TITLE, R.style.fragment_dialog);
    }

 

以上就是短视频直播源码,DialogFragment全屏且半透明, 更多内容欢迎关注之后的文章

 

这篇关于短视频直播源码,DialogFragment全屏且半透明的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!