Missing Dialog Buttons under Android 7.1.1

若如初见. 提交于 2019-12-05 06:40:49

The solution which is working for me was to add the following lines on my style.xml :

// your main style
<style name="YourStyleName" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="android:alertDialogTheme">@style/AlertDialogTheme</item>
    <item name="alertDialogTheme">@style/AlertDialogTheme</item>
</style>

// dialog style
<style name="AlertDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="buttonBarButtonStyle">@style/DialogButtonStyle</item>
</style>

// button's dialog style
<style name="DialogButtonStyle" parent="@style/Widget.AppCompat.Button.ButtonBar.AlertDialog">
    <item name="android:textColor">@color/colorPrimary</item>
</style>

It's working perfectly, I hope it will help you guys.

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