emr*_*e26 23

试试下面的代码

AlertDialog.Builder alertDialog = new AlertDialog.Builder(this,android.R.style.Theme_Black_NoTitleBar_Fullscreen);
Run Code Online (Sandbox Code Playgroud)


Sar*_*ern 14

您必须为对话框创建自定义样式

在你的style.xml中

 <style name="DialogTheme" parent="android:Theme.Dialog">

    <item name="android:layout_width">fill_parent</item>
    <item name="android:layout_height">fill_parent</item>   
    <!-- No backgrounds, titles or window float -->
    <item name="android:windowBackground">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)

在膨胀对话框时设置此主题

dialog = new Dialog(this, R.style.DialogTheme);


Sam*_*hen 11

?方法一| 使用自定义样式?

在样式文件中:

<style name="myFullscreenAlertDialogStyle" parent="Theme.AppCompat.Light.NoActionBar">      //no actionbar, but status bar exists
    <item name="android:windowFullscreen">true</item>                       //remove status bar
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>        //smooth animation
    <item name="colorAccent">@color/colorAccent</item>                      //change button text color
</style>
Run Code Online (Sandbox Code Playgroud)

在java文件中:

AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), R.style.myFullscreenAlertDialogStyle);   //second argument
Run Code Online (Sandbox Code Playgroud)

?方法2 | 使用内置样式?

在java文件中:

AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity(), android.R.style.Theme_Material_Light_NoActionBar_Fullscreen);
Run Code Online (Sandbox Code Playgroud)
  • 这个方法会使按钮文字变成绿色,你可以用dialog.getButton().setTextColor()它来改变它。