Change the style of AlertDialog

懵懂的女人 提交于 2019-11-29 02:30:17

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 );

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" 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!