android DatePicker样式

第一次使用日期选择器
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_margin="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="请选择日期"
android:gravity="center"/>
<DatePicker
android:id="@+id/date_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_gravity="center"></DatePicker>
</LinearLayout>
发现我的选择器是这个样子的

QQ图片20170724121250.png

可是我需要的样子是这个样子的

QQ图片20170724121842.png

问了群友,没有直接得到答案。
最后还是百度到了结果。
在DatePicker加一句样式控制就可以了。
android:theme="@android:style/Theme"

顺便整理下android系统自带的各种样式
使用Android提供的Style和Theme:
Android平台提供了大量的styles和themes,可以在android包中的R.style下找到,但是Android现在并未提供关于styles和themes的相关文档说明,具体可以参考styles.xml源码themes.xml源码 ,扫了一下,描述的很清楚。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容