Keep Alertdialog Default Layout Params Using Custom Window Background
I need a dialog with custom background color and rounded corners. How can I keep default layout params using custom window background for AlertDialog? Currently, my dialog has sma
Solution 1:
Should use this when creating AlertDialog: new AlertDialog.Builder(context, R.style.MyDialog)
<stylename="DialogBarButton"parent="Widget.AppCompat.Button.ButtonBar.AlertDialog"><itemname="android:textColor">@color/button_bar_enabled_selector</item></style><stylename="DialogBase"parent="Theme.AppCompat.Light.Dialog.Alert"><itemname="android:windowMinWidthMajor">@dimen/dialog_min_width_major</item><itemname="android:windowMinWidthMinor">@dimen/dialog_min_width_minor</item><itemname="android:windowAnimationStyle">@style/Animation.AppCompat.Dialog</item><itemname="android:buttonBarButtonStyle">@style/DialogBarButton</item></style><stylename="MyDialog"parent="DialogBase"><itemname="android:windowBackground">@drawable/bg_custom</item></style>
values/dimens.xml:
<dimenname="dialog_min_width_major">65%</dimen><dimenname="dialog_min_width_minor">85%</dimen>
color/button_bar_enabled_selector.xml:
<selectorxmlns:android="http://schemas.android.com/apk/res/android"><itemandroid:color="@color/colorAccent"android:state_enabled="true" /><itemandroid:color="@color/TextDisabled"/></selector>
I don't know why color of dialog bar buttons had changed in this case. To fix this issue I have to use selector with colors for enabled and disabled states.
Post a Comment for "Keep Alertdialog Default Layout Params Using Custom Window Background"