简体   繁体   English

如何修复DatePicker设计

[英]How to fix DatePicker Design

I'm having issues with the datepicker design. 我在datepicker设计上遇到问题。 I'm having different design when I'm seeing it on eclipse screen and when I run it on emulator it shows me different design. 当我在Eclipse屏幕上看到它时,我有不同的设计,而当我在模拟器上运行它时,则显示出不同的设计。 Screenshots and code are below. 屏幕截图和代码如下。

<DatePicker
    android:id="@+id/added_date"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:calendarViewShown="false"
    android:soundEffectsEnabled="false" />

Code which I'm using in values/styles.xml . 我在values/styles.xml使用的代码。 If I don't use this code I get a whole different datepicker. 如果我不使用此代码,则会得到一个完全不同的日期选择器。

<item name="android:datePickerStyle">@android:style/Widget.DatePicker</item>

Eclipse screenshot: Eclipse屏幕截图:

Eclipse屏幕截图

Emulator screenshot: 模拟器截图:

模拟器截图

This is a result of the Android OS version you are running: the later is from 4.0 (or 3.x holo) and up, the the former is 2.x and below. 这是您运行的Android OS版本的结果:后者是从4.0(或3.x holo)及更高版本开始,前者是2.x及以下版本。 The style is dependent on the os version: instead of relying on the sdk, you might use a third party library (where the style is defined and not dependent on the os version: look here https://android-arsenal.com/search?q=date+picker for what you might want. 样式取决于os版本:您可以不使用sdk,而可以使用第三方库(其中定义了样式,而不依赖于os版本:请参见https://android-arsenal.com/search ?q = date + picker可能需要的内容。

Note you can change the style to reflect a particular os version in the preview, by looking for for the Android icon with the number next to it, and selecting which os version you want the preview to reflect. 请注意,您可以更改样式以在预览中反映特定的OS版本,方法是查找旁边带有数字的Android图标,然后选择要反映预览的OS版本。

If you don't want to use a third party library, you can force the style of the datepicker by rewritting the theme style, for reference check this post out: datepicker with different style than activity 如果您不想使用第三方库,则可以通过重新编写主题样式来强制使用日期选择器的样式,以供参考,请查看此文章: 日期选择器的样式不同于活动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM