如何更改 Android 的 Datepicker 样式 [英] How to Change the Datepicker style for Android

查看:72
本文介绍了如何更改 Android 的 Datepicker 样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在制作注册表,其中一个字段是用户的出生日期.我想使用日期选择器,但是我不想要如下所示的日历布局:

I'm currently making a registration form, and one of the fields is for the users Date of Birth. I want to use datepicker, however I don't want the calendar layout as shown below:

我希望布局看起来像这样,这样可以更轻松地选择年份和月份,而无需滚动浏览所有内容:

I want the layout to look something like this so that way its easier to choose the year and month without having to scroll through everything:

但是我不知道该怎么做,或者在styles.xml文件中放什么.任何帮助将不胜感激.

However I do not know how to go about this, or what to put inside the styles.xml file. Any help would be greatly appreciated.

推荐答案

将此添加到 style.xml

<style name="date_picker_theme" parent="@android:style/Widget.DatePicker">

然后你应该像这样为你的日期选择器应用样式:

And then you should apply style for your date picker like this:

<DatePicker
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/datePicker"
        style="@style/date_picker_theme" />

这篇关于如何更改 Android 的 Datepicker 样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆