Reputation: 167
I've tried to change the color of text and background in Alertdialog to white text and transparent background. However, it didn't work.
Please refer to below and let me know what did I miss. Thank you.
Note: Android with Kotlin
*** 1. Code in Main Activity ***
*** 2. Style.xml ***
Upvotes: 1
Views: 254
Reputation: 1670
For transparent dialog, you need to set android:background
change your style like
<style name="MyDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:background">@android:color/transparent</item>
</style>
UPDATE
<style name="myAlertdialogstyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:textColorPrimary">@android:color/white</item>
<item name="android:textColor">@android:color/white</item>
</style>
Upvotes: 1
Reputation: 289
<style name="MyAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert"> <item name="android:background">@color/Black</item> <item name="colorAccent">@color/White</item> </style>
Here android:Background is android property so it will automatically reflect to your dialog
also you should use Theme.AppCompat.Light.Dialog.Alert instead of Theme.AppCompat.Light.Dialog
Upvotes: 1