Android Material Design 5.0 PickerDialog
5.0系统下的时间选择器效果图:
该项目兼容到3.0下面所以用第三方开源项目:actionbarsherlock,动画效果兼容:nineoldandroids-2.4.0.jar,格式转换器:joda-time-2.1.jar
主要调用代码实例:
import org.joda.time.DateTime; import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.text.format.DateFormat;
import android.widget.Toast; import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.doomonafireball.betterpickers.calendardatepicker.CalendarDatePickerDialog;
import com.doomonafireball.betterpickers.radialtimepicker.RadialTimePickerDialog; public class MainActivity extends SherlockFragmentActivity implements CalendarDatePickerDialog.OnDateSetListener, RadialTimePickerDialog.OnTimeSetListener { public static final String FRAG_TAG_TIME_PICKER = "timePickerDialogFragment";
public static final String FRAG_TAG_DATE_PICKER = "fragment_date_picker_name";
private boolean mHasDialogFrame; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); /*FragmentManager fm = getSupportFragmentManager();
DateTime now = DateTime.now();
CalendarDatePickerDialog calendarDatePickerDialog = CalendarDatePickerDialog
.newInstance(this, now.getYear(), now.getMonthOfYear() - 1,
now.getDayOfMonth());
calendarDatePickerDialog.show(fm, FRAG_TAG_DATE_PICKER);*/
if (savedInstanceState == null) {
mHasDialogFrame = findViewById(R.id.frame) != null;
} DateTime now = DateTime.now();
RadialTimePickerDialog timePickerDialog = RadialTimePickerDialog
.newInstance(this, now.getHourOfDay(), now.getMinuteOfHour(),
DateFormat.is24HourFormat(this));
if (mHasDialogFrame) {
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); ft.add(R.id.frame, timePickerDialog, FRAG_TAG_TIME_PICKER)
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
.commit();
} else {
timePickerDialog.show(getSupportFragmentManager(), FRAG_TAG_TIME_PICKER);
}
} @Override
public void onResume() {
// Example of reattaching to the fragment
super.onResume();
/*CalendarDatePickerDialog calendarDatePickerDialog = (CalendarDatePickerDialog) getSupportFragmentManager()
.findFragmentByTag(FRAG_TAG_DATE_PICKER);
if (calendarDatePickerDialog != null) {
calendarDatePickerDialog.setOnDateSetListener(this);
}*/ RadialTimePickerDialog rtpd = (RadialTimePickerDialog) getSupportFragmentManager().findFragmentByTag(
FRAG_TAG_TIME_PICKER);
if (rtpd != null) {
rtpd.setOnTimeSetListener(this);
}
} @Override
public void onTimeSet(RadialTimePickerDialog dialog, int hourOfDay,
int minute) {
// TODO Auto-generated method stub
String result="" + hourOfDay + ":" + minute;
Toast.makeText(this, result, Toast.LENGTH_SHORT).show();
} @Override
public void onDateSet(CalendarDatePickerDialog dialog, int year,
int monthOfYear, int dayOfMonth) {
// TODO Auto-generated method stub
String result="Year: " + year + "\nMonth: " + monthOfYear + "\nDay: " + dayOfMonth;
Toast.makeText(this, result, Toast.LENGTH_SHORT).show();
}
}
Theme:
<application android:allowBackup="true" android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:theme="@style/Theme.Sherlock.Light.DarkActionBar">
界面颜色风格改动:
<? xml version="1.0" encoding="utf-8"?>
<resources>
<color name="transparent">#00000000</color>
<color name="default_text_color_holo_dark">#ffffffff</color>
<color name="default_text_color_holo_dark_disabled">#ff4c4c4c</color>
<color name="default_divider_color_dark">#28ffffff</color>
<color name="default_button_background_dark">#00000000</color>
<color name="default_button_background_pressed_dark">#46c5c1ff</color>
<color name="default_keyboard_indicator_color_dark">#ff33b5e5</color> <color name="default_text_color_holo_light">#ff000000</color>
<color name="default_text_color_holo_light_disabled">#ffb2b2b2</color>
<color name="default_divider_color_light">#28000000</color>
<color name="default_button_background_light">#00000000</color>
<color name="default_button_background_pressed_light">#ff00ddff</color>
<color name="default_keyboard_indicator_color_light">#ff00ddff</color> <color name="white">#ffffff</color>
<color name="circle_background">#f2f2f2</color>
<color name="line_background">#cccccc</color>
<color name="ampm_text_color">#8c8c8c</color>
<color name="done_text_color_normal">#000000</color>
<color name="done_text_color_disabled">#cccccc</color>
<color name="numbers_text_color">#8c8c8c</color> <color name="transparent_black">#7f000000</color>
<color name="blue">#33b5e5</color>
<color name="blue_focused">#c1e8f7</color>
<color name="neutral_pressed">#33999999</color>
<color name="darker_blue">#0099cc</color>
<color name="date_picker_text_normal">#ff999999</color> <color name="calendar_header">#999999</color>
<color name="date_picker_view_animator">#f2f2f2</color>
<color name="calendar_selected_date_text">#ffd1d2d4</color> <!-- Colors for red theme -->
<color name="red">#ff3333</color>
<color name="red_focused">#853333</color>
<color name="light_gray">#404040</color>
<color name="dark_gray">#363636</color>
<color name="line_dark">#808080</color>
<color name="done_text_color_dark_normal">#ffffff</color>
<color name="done_text_color_dark_disabled">#888888</color>
<color name="done_disabled_dark">#bfbfbf</color> <color name="recurrence_picker_background">#fff2f2f2</color>
<color name="recurrence_bubble_text_normal">#ff737373</color>
</resources>
比方:
<color name="calendar_header">#cfcfcf</color>
改动星期几相应的TextView 的背景色,详细颜色含义參考 Dialog定义
以下是全部源代码下载地址:http://download.csdn.net/detail/anddroid_lanyan/8839177
Android Material Design 5.0 PickerDialog的更多相关文章
- Android Material Design Ripple Effect在Android5.0(SDK=21)以下Android版本崩溃问题解决
Android Material Design Ripple Effect在Android5.0(SDK=21)以下Android版本崩溃问题解决 附录1的Android Ripple Effect水 ...
- Android Material Design 兼容库的使用
Android Material Design 兼容库的使用 mecury 前言:近来学习了Android Material Design 兼容库,为了把这个弄懂,才有了这篇博客,这里先推荐两篇博客: ...
- Android Material Design : Ripple Effect水波波纹荡漾的视觉交互设计
Android Material Design : Ripple Effect水波波纹荡漾的视觉交互设计 Android Ripple Effect波纹荡漾效果,是Android Materia ...
- Android Material Design的FloatingActionButton,Snackbar和CoordinatorLayout
如果是为了兼容低版本的Android系统,则需要引用Android Material Design的扩展支持库,我在之前的一篇文章张,较为详细的说明了如何导入Android Material Desi ...
- MaterialEditText——Android Material Design EditText控件
MaterialEditText是Android Material Design EditText控件.可以定制浮动标签.主要颜色.默认的错误颜色等. 随着 Material Design 的到来, ...
- Android Material Design控件学习(三)——使用TextInputLayout实现酷市场登录效果
前言 前两次,我们学习了 Android Material Design控件学习(一)--TabLayout的用法 Android Material Design控件学习(二)--Navigation ...
- Could not resolve com.android.support:design 28.0.0
想试一试android的那个侧滑栏功能,需要用到 'com.android.support:design:28.0.0'建好之后一直报关于28.00的错误,一开始各种百度更改配置没吊用,最后感觉是网络 ...
- Android Material Design控件学习(一)——TabLayout的用法
前言 Google官方在14年Google I/O上推出了全新的设计语言--Material Design.一并推出了一系列实现Material Design效果的控件库--Android Desig ...
- Android Material Design简单使用
吐槽 作为一个 Android developer,没有什么比拿着 UI 设计的一堆 iOS 风格的设计 来做需求更恶心的了,基本所有空间都要照着 iOS 来画一遍,Material Design 辣 ...
随机推荐
- Bag of Features (BOF)图像检索算法
1.首先.我们用surf算法生成图像库中每幅图的特征点及描写叙述符. 2.再用k-means算法对图像库中的特征点进行训练,生成类心. 3.生成每幅图像的BOF.详细方法为:推断图像的每一个特征点与哪 ...
- jquery模拟可输入的下拉框
//页面html <div id="select" class="select" > <ul> <c:forEach items= ...
- Android学习笔记进阶八之Matrix矩阵
Matrix,中文里叫矩阵,高等数学里有介绍,在图像处理方面,主要是用于平面的缩放.平移.旋转等操作. 在Android里面,Matrix由9个float值构成,是一个3*3的矩阵.最好记住.如下图: ...
- startActivity时报错Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag
startActivity时报错Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVI ...
- 方正飞越 A600硬改BIOS激活win7的工具与方法。
硬件:方正飞越A600-4E57:主板,H61 IPISB-VR:BIOS版本,方正A007SB0(AMI) 软件:Win7专业版 目标:修改BIOS,添加SLIC2.1,硬激活win7 OEM版 具 ...
- Python画图参数设置
https://blog.csdn.net/qiu931110/article/details/68130199
- h5背景
1.背景属性复习: background-image background-color background-repeat background-position background-attachm ...
- 转载的:Python os 和 os.path模块详解
os.getcwd()获取当前工作目录,即当前python脚本工作的目录路径 os.chdir("dirname") 改变当前脚本工作目录:相当于shell下cd os.curdi ...
- [appium]-9宫格解锁方法
from appium.webdriver.common.touch_action import TouchAction TouchAction(self.driver).press(x=228,y= ...
- 【例题 7-1 UVA - 725】Division
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举分母从0到99999. 得到分子,判断合法 [代码] /* 1.Shoud it use long long ? 2.Have ...