android - Alertdialog in Material Design -
i follow http://www.laurivan.com/make-dialogs-obey-your-material-theme/ style alertdialog in material design style. however, found out still can't style same site, following code , screenshot:
values-v14/styles.xml:
<!-- base application theme api 14+. theme replaces appbasetheme both res/values/styles.xml , res/values-v11/styles.xml on api 14+ devices. --> <style name="appbasetheme" parent="android:theme.holo.light.darkactionbar"> <!-- api 14 theme customizations can go here. --> </style> <style name="apptheme" parent="theme.appcompat.light.darkactionbar"> <item name="android:windowcontentoverlay">@null</item> <item name="android:windowactionbaroverlay">true</item> <!-- colorprimary used default action bar background --> <item name="colorprimary">@color/colorprimary</item> <!-- colorprimarydark used status bar --> <item name="colorprimarydark">@color/colorprimarydark</item> <item name="android:dialogtheme">@style/mydialogtheme</item> <item name="android:alertdialogtheme">@style/mydialogtheme</item> </style> <style name="mydialogtheme" parent="theme.appcompat.light.dialog.alert"> <item name="android:windowbackground">@color/transparent</item> <item name="android:windowcontentoverlay">@null</item> <item name="android:windowisfloating">true</item> <item name="android:windowcloseontouchoutside">false</item> </style>
values/color.xml
<resources> <color name="colorprimarydark">#3367d6</color> <color name="colorprimary">#4285f4</color> <color name="windowbackgroundcolor">#eeeeee</color> <color name = "transparent">#0000</color> </resources>
screenshot:
i want divider removed , btn in padding right style, thanks!
with new appcompat v22.1
can use new android.support.v7.app.alertdialog.
just use code this:
import android.support.v7.app.alertdialog alertdialog.builder builder = new alertdialog.builder(this, r.style.appcompatalertdialogstyle); builder.settitle("dialog"); builder.setmessage("lorem ipsum dolor ...."); builder.setpositivebutton("ok", null); builder.setnegativebutton("cancel", null); builder.show();
and use style this:
<style name="appcompatalertdialogstyle" parent="theme.appcompat.light.dialog.alert"> <item name="coloraccent">#ffcc00</item> <item name="android:textcolorprimary">#ffffff</item> <item name="android:background">#5fa3d0</item> </style>
you can use single style file devices.