如何改变的DatePicker的默认颜色和TimePicker对话框中的Android? [英] How to change the default color of DatePicker and TimePicker dialog in Android?
问题描述
有没有办法改变的默认颜色的DatePicker
和 TimePicker
对话框?
这是在code我试图
<的DatePicker
风格=@风格/ date_picker
机器人:后台=#6495ED
机器人:ID =@ + ID / DatePicker的
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =5DP
机器人:layout_marginBottom =5DP
机器人:layout_marginLeft =5dip
机器人:layout_marginRight =5dip/>
< TimePicker
机器人:ID =@ + ID / TimePicker
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =5DP
机器人:layout_marginBottom =5DP
机器人:layout_marginLeft =5dip
机器人:layout_marginRight =5dip/>
下面第二行仅改变背景颜色,我想更改日期和时间选择器的默认银色。
任何帮助,请。
风格=@风格/ date_picker
机器人:后台=#6495ED
您必须创建一个自定义主题,并将其保存在某些目录最终确定这个主题为默认一个用于应用程序
首先,在价值增加的themes.xml是这样的:
< XML版本=1.0编码=UTF-8&GT?;
<资源>
<样式名称=MyAppTheme父=@安卓风格/ Theme.Light.NoTitleBar>
<! - 在pre-3.0的设备上运行的任何自定义您的应用程序在这里 - >
< /风格>
< /资源>
然后,创建一个名为价值-V11(安卓3.0+)在res目录的目录,并把一个的themes.xml这样
< XML版本=1.0编码=UTF-8&GT?;
<资源>
<样式名称=MyAppTheme父=@安卓风格/ Theme.Holo.Light>
<! - 在3.0+设备上运行的任何自定义您的应用程序在这里 - >
< /风格>
< /资源>
最后,创建一个名为价值-V14(安卓4.0+)在res目录的目录并创建的themes.xml
< XML版本=1.0编码=UTF-8&GT?;
<资源>
<样式名称=MyAppTheme父=@安卓风格/ Theme.DeviceDefault.Light.NoActionBar>
<! - 在4.0以上版本的设备上运行的任何自定义您的应用程序在这里 - >
< /风格>
< /资源>
最后,在你的manifest.xml
<应用
...
机器人:主题=@风格/ MyAppTheme>
Is there any way to change the default color of DatePicker
and TimePicker
dialog?
This is the code I tried
<DatePicker
style="@style/date_picker"
android:background="#6495ED"
android:id="@+id/DatePicker"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip" />
<TimePicker
android:id="@+id/TimePicker"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip" />
Below two line only changing the background color, I want to change the default silver color of both date and time picker.
Any help please.
style="@style/date_picker"
android:background="#6495ED"
You have to create a custom theme and save it in some directories to finally set this theme as the default one for the app
First, in values add a themes.xml like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyAppTheme" parent="@android:style/Theme.Light.NoTitleBar">
<!-- Any customizations for your app running on pre-3.0 devices here -->
</style>
</resources>
Then, create a directory with the name "values-v11" (Android 3.0+ ) in the res directory and put a themes.xml like this
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyAppTheme" parent="@android:style/Theme.Holo.Light">
<!-- Any customizations for your app running on 3.0+ devices here -->
</style>
</resources>
Finally, create a directory with the name "values-v14" (Android 4.0+) in the res directory and create a themes.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyAppTheme" parent="@android:style/Theme.DeviceDefault.Light.NoActionBar">
<!-- Any customizations for your app running on 4.0+ devices here -->
</style>
</resources>
Finally in your manifest.xml
<application
...
android:theme="@style/MyAppTheme">
这篇关于如何改变的DatePicker的默认颜色和TimePicker对话框中的Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!