I have a simple dialog box with two buttons, Positive and Negative that is taking a simple style layout I have defined in the styles.xml. I want the cancel button to have a clear background but still have user feedback when touching it (like a ripple effect of red). I've tried for 2 days now and no luck. Any input would be great.
Working with Ripple Effect:
My code for the next layout which makes the layout have a clear background for cancel but no ripple effect. But I do get a ripple effect for the Yes:
<style name="AlertDialogThemeTesting" parent="Theme.AppCompat.Dialog.Alert">
<item name="colorControlHighlight">@color/Red</item>
<item name="colorControlActivated">@color/Red</item>
<item name="colorControlNormal">@color/Red</item>
<item name="android:textColor">@color/Black</item>
<item name="android:textColorPrimary">@color/Gray</item>
<item name="android:buttonBarNegativeButtonStyle">@style/NegativeButtonStyle</item>
<item name="android:buttonBarPositiveButtonStyle">@style/PositiveButtonStyle</item>
</style>
<style name="NegativeButtonStyle" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
<item name="android:textColor">@color/Black</item>
<item name="android:background">?attr/selectableItemBackgroundBorderless</item>
<item name="backgroundTint">@color/Clear</item>
</style>
<style name="PositiveButtonStyle" parent="Widget.AppCompat.Button.ButtonBar.AlertDialog">
<item name="android:textColor">@color/Black</item>
<item name="android:background">?attr/selectableItemBackgroundBorderless</item>
<item name="android:backgroundTint">@color/Gold</item>
</style>
Clear Background but no Ripple Effect:
It seems like adding a Clear/White background removes the ripple effect for some reason.
Code for Dialog:
final AlertDialog.Builder alert = new AlertDialog.Builder(PopOut.this,
R.style.AlertDialogTheme);
alert .setTitle("Delete Profile?")
.setMessage("Are you sure you want to delete" + profile)
.setPositiveButton("OK",
new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface dialog,
int whichButton)
{
finish();
dialog.dismiss();
}
})
.setNegativeButton("Cancel", null);
final AlertDialog dialog = alert.create();
dialog.show();