开发工具:eclipse
测试手机:华为MT2,金立Go、红米note4x
final Calendar calendar = Calendar.getInstance();
DatePickerDialog dialog = new DatePickerDialog(
Activity_OpticalSplitter.this, R.style.AppTheme_AppDate,
new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
calendar.set(year, monthOfYear, dayOfMonth);
SimpleDateFormat format = new SimpleDateFormat(
"yyyy年MM月dd日");
Time_edit.setText(format.format(calendar.getTime()));
}
}, calendar.get(Calendar.YEAR), calendar
.get(Calendar.MONTH), calendar
.get(Calendar.DAY_OF_MONTH));
dialog.show();
style
<style name="AppTheme.AppDate" parent="android:Theme.Holo.Light.NoActionBar" tools:ignore="NewApi">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<!-- 设置dialog不全屏 -->
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowNoTitle">true</item>
<!-- 除去title,如果在代码里面有其他设置会没效果的不过完全没效果 -->
<item name="android:windowContentOverlay">@null</item>
<item name="android:backgroundDimEnabled">false</item>
<!-- <item name="android:windowBackground">@null</item><!–除去背景色–> -->
</style>