目标:弹出一个对话框
进化①
程序猿:Dialog 真难看,设置一下样式吧。
public class SumileNumberPickerDialog extends AlertDialog
首先我自定义了一个类,继承了 AlertDialog,然后我们就看到了他的构造方法
程序猿:窝草,这里有设置 Theme 的地方哎~
于是,程序猿欢快的写下了下面的代码:
一运行:
程序猿:黑了个嘿嘿嘿,dialog 好了,里面的 numberPicker 怎么可以那么丑!
进化②
程序猿:既然 Dialog 可以设置 Theme,那么 NumberPicker 是不是也可以呢?
呵:
A widget that enables the user to select a number form a predefined range. There are two flavors of this widget and which one is presented to the user depends on the current theme. If the current theme is derived from android.R.style.Theme the widget presents the current value as an editable input field with an increment button above and a decrement button below. Long pressing the buttons allows for a quick change of the current value. Tapping on the input field allows to type in a desired value. If the current theme is derived from android.R.style.Theme_Holo or android.R.style.Theme_Holo_Light the widget presents the current value as an editable input field with a lesser value above and a greater value below. Tapping on the lesser or greater value selects it by animating the number axis up or down to make the chosen value current. Flinging up or down allows for multiple increments or decrements of the current value. Long pressing on the lesser and greater values also allows for a quick change of the current value. Tapping on the current value allows to type in a desired value. For an example of using this widget, see android.widget.TimePicker.
看到没,和系统的主题有关~
可是,我系统主题是对的啊
哎,我记得 Activity 也可以设置 Theme 啊,Dialog 是依赖于 Activity 的,那 Dialog 的样式是不是因为 Activity 呢?
窝草
谁干的!这里加毛 Theme。。
去掉之后的效果:
结果
客户:嘿嘿嘿
转载请注明:热爱改变生活.cn » Android 中对 Dialog 以及 NumberPicker 的配置
本博客只要没有注明“转”,那么均为原创。 转载请注明链接:sumile.cn » Android 中对 Dialog 以及 NumberPicker 的配置