<style name="MyAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<!-- Used for the buttons -->
<item name="colorAccent">@color/colorAccent</item>
<!-- Used for the title and text -->
<!-- <item name="android:textColorPrimary">@color/colorAccent</item>-->
<!-- Used for the background -->
<!-- <item name="android:background">@color/white</item>-->
</style>
new AlertDialog.Builder(mActivity, R.style.MyAlertDialogStyle)
.setPositiveButton("好的", (dialog, which) -> dialog.dismiss())
.setCancelable(false)
.setMessage(message)
.show();
注意:以上设置针对android所有版本都能生效。
本文介绍如何在Android应用中自定义AlertDialog的样式,包括按钮颜色、背景颜色等,并展示了如何使用自定义样式创建对话框,确保在所有Android版本上的一致性。
940

被折叠的 条评论
为什么被折叠?



