android custom dialog background

前端 未结 5 702
故里飘歌
故里飘歌 2021-01-05 05:45

I need to show a custom dialog in my Android application. Standard AlertDialog design is unacceptable. Android docs say:

Tip: If you want

相关标签:
5条回答
  • 2021-01-05 06:04
    dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    
    0 讨论(0)
  • 2021-01-05 06:05

    i have used this as a style:

    <style name="DialogTransparent" parent="Theme.AppCompat.Dialog">
        <item name="android:windowFrame">@null</item>
        <item name="android:windowBackground">@android:color/transparent</item>
        <item name="android:windowIsFloating">true</item>
        <item name="android:windowContentOverlay">@null</item>
        <item name="android:windowTitleStyle">@null</item>
        <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
        <item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
    
        <item name="android:background">@android:color/transparent</item>
    </style>
    <!-- <item name="android:backgroundDimEnabled">false</item> -->
    

    it has also background transparent, setting the brackgroundDimEnabled parameter to false works for not showing the gray background that shows with the dialog in his back.

    0 讨论(0)
  • 2021-01-05 06:09

    Try...

    You can avoid the gray background like this, Here I did get transparent background.

        ........
        Dialog dialog = new Dialog(MainActivity.this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        Window window = dialog.getWindow();
        window.setBackgroundDrawableResource(android.R.color.transparent);
        dialog.setContentView(R.layout.popup_layout);
        Button dialogBtn= (Button) dialog.findViewById(R.id.btn);
    
        dialogBtn.setOnClickListener(new View.OnClickListener() {
    
            @Override
            public void onClick(View v) {
                //task
            }
        });
        dialog.show();
        .......
    
    0 讨论(0)
  • 2021-01-05 06:12
    dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
    
    0 讨论(0)
  • 2021-01-05 06:25

    make theme like this

    <style name="ThemeDialogCustom">
    <item name="android:windowFrame">@null</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowAnimationStyle">@android:style/Animation.Dialog</item>
    <item name="android:windowBackground">@color/transparent</item>
    <item name="android:colorBackgroundCacheHint">@null</item>
    </style>
    
    0 讨论(0)
提交回复
热议问题