I want to change the background of the Alert dialog. I have tried following code piece to do so:
<style name="Theme.AlertDialog" parent="@android:style/Theme.Holo.Light.Dialog">
<item name="android:background">@android:color/transparent</item>
<item name="android:textColor">#659F26</item>
<item name="android:windowTitleStyle">@style/Theme.AlertDialog.Title</item>
</style>
<style name="Theme.AlertDialog.Title" parent="@android:style/TextAppearance.DialogWindowTitle">
<item name="android:background">@drawable/cab_background_top_example</item>
</style>
Java Code:
ContextThemeWrapper ctw = new ContextThemeWrapper( this, R.style.Theme_AlertDialog);
final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctw);
alertDialogBuilder.setTitle(getResources().getString(R.string.confirmation));
alertDialogBuilder.setMessage(getResources().getString(R.string.msg));
alertDialogBuilder.show();
My app is showing dialog like this:
while i want it to look like:
Please suggest, what i am doing wrong.
To change the background color of all dialogs and pop-ups in your app, use colorBackgroundFloating attribute. Save this answer. Show activity on this post. I was looking at the material.io/components/dialogs/android#full-screen-dialog where the container color element has no attribute.
To do this you use alert builder to build your alert. You then get the TextView from this alert and then you set the typeface for the alert. That's good, remember to approve and upvote once you get the privileges so other people can get this help too.
Use this code when creating a dialog:
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
create your own layout As many customise done with title then set your layout
dialog.setContentView(R.layout.yourlayout);
NOTE: use
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); before
dialog.setContentView(R.layout.yourlayout);
otherwise it give error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With