code:
<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/activeRed</item>
<item name="android:textColorPrimary">@color/colorWhite</item>
<item name="android:background">@color/colorSecondary</item>
</style>
CodePudding user response:
Step 1 : declare colorAccent and text color to style like this
<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/yourColor</item>
<item name="android:textColor">@color/teal_200</item>
<item name="android:textColorPrimary">@color/colorWhite</item>
<item name="android:background">@color/colorSecondary</item>
</style>
Step 2: assign this style to your dialog like this:
AlertDialog.Builder builder = new
AlertDialog.Builder(MainActivity.this,
R.style.AppCompatAlertDialogStyle);
Have fun.
CodePudding user response:
Try this - STEP 1-
val builder: AlertDialog.Builder = AlertDialog.Builder(this, R.style.AlertDialog)
builder.setTitle("THIS IS TEST")
builder.setPositiveButton(
"Yes"
) { _, _ -> Log.e("LOG_TAG", "Yes") }
builder.setNegativeButton(
"No"
) { _, _ -> Log.e("LOG_TAG", "No") }
builder.create()
builder.show()
STEP 2- Add in style.xml
<style name="AlertDialog" parent="Theme.MaterialComponents.Light.Dialog.Alert">
<item name="android:textColor">#FF0000</item>
<item name="android:textColorPrimary">#C51162</item>
<item name="android:colorAccent">#11EA21</item>
</style>