Change the style of AlertDialog

前端 未结 2 1420
难免孤独
难免孤独 2020-12-16 06:04

When I run this code the alert dialog is shown but there is one white border around the dialog and also the borders are little round. I do not want this white border and I w

相关标签:
2条回答
  • 2020-12-16 06:37

    I found solution with the wrapper, where you can set a theme (style) to anything in the current context. I set R.style.MyTheme as style to my alert dialog and I customized that view to my own taste.

    ContextThemeWrapper ctw = new ContextThemeWrapper( this, R.style.MyTheme );
            AlertDialog.Builder builder= new AlertDialog.Builder( ctw );
    
    0 讨论(0)
  • 2020-12-16 06:51

    You answered your question yourself but it did not work for me, so here's my answer hope to be helpful for everyone who need it:

    <style name="PauseDialog" parent="@android:style/Theme.Dialog">
            <item name="android:windowNoTitle">true</item>
            <item name="android:windowBackground">@android:color/transparent</item>
    
    </style>
    

    Put this style in res\values\styles.xml file and just set the theme of your activity to it in your Manifest. Like this:

    android:theme="@style/PauseDialog" 
    
    0 讨论(0)
提交回复
热议问题