linear-time-picker
介绍:
一个类似Timely app时间选择效果的控件。
运行效果:
使用说明:
Step 1
Gradle
dependencies {
compile 'net.codecrafted:lineartimepicker:1.0.0'
}
Step 2
LinearTimePickerDialog
使用builder模式来创建一个dialog,下面是创建一个最基本的dialog所需的代码。
LinearTimePickerDialog dialog = LinearTimePickerDialog.Builder.with(context)
/* methods to further customize the dialog go here */
.build();
显示跟其他的AlertDialog是一样的:
dialog.show();
为了进一步自定义LinearTimePickerDialog,可以使用如下方法:
// Set the background color of the dialog (1)
setDialogBackgroundColor(int color)
// Set the background color of the picker inside the dialog (2)
setPickerBackgroundColor(int color)
// Set the color of the unselected lines in the linear dial (3)
setLineColor(int color)
// Set the color of all the displayed text
setTextColor(int color)
// Show a short 10 second automated tutorial to onboard the user
setShowTutorial(boolean showTutorial)
// Set the background color of the "handle" (4)
setTextBackgroundColor(int color)
// Set the color of the two buttons at the top of the dialog (5)
setButtonColor(int color)
// Register a callback when the selection process is completed or canceled
setButtonCallback(new LinearTimePickerDialog.ButtonCallback() {
@Override
public void onPositive(DialogInterface dialog, int hour, int minutes) {
Toast.makeText(MainActivity.this, "" + hour + ":" + minutes, Toast.LENGTH_SHORT).show();
}
@Override
public void onNegative(DialogInterface dialog) {
}
})
LinearDatePickerDialog
使用builder模式来创建一个dialog,下面是创建一个最基本的DatePickerDialog所需的代码。
LinearDatePickerDialog dialog = LinearDatePickerDialog.Builder.with(context)
/* methods to further customize the dialog go here */
.build();
显示:
dialog.show();
为了进一步自定义LinearDatePickerDialog,可以使用如下方法:
// Year that will be selected when the dialog is shown
setYear(int year)
// Minimum year that is allowed to be selected (inclusive)
setMinYear(int year)
// Maximum year that is allowed to be selected (inclusive)
setMaxYear(int year)
// Set the background color of the dialog (1)
setDialogBackgroundColor(int color)
// Set the background color of the picker inside the dialog (2)
setPickerBackgroundColor(int color)
// Set the color of the unselected lines in the linear dial (3)
setLineColor(int color)
// Set the color of all the displayed text
setTextColor(int color)
// Show a short 10 second automated tutorial to onboard the user
setShowTutorial(boolean showTutorial)
// Set the background color of the "handle" (4)
setTextBackgroundColor(int color)
// Set the color of the two buttons at the top of the dialog (5)
setButtonColor(int color)
// Register a callback when the selection process is completed or canceled
setButtonCallback(new LinearDatePickerDialog.ButtonCallback() {
@Override
public void onPositive(DialogInterface dialog, int year, int month, int day) {
Toast.makeText(MainActivity.this, "" + year + " - " + month + " - " + day, Toast.LENGTH_SHORT).show();
}
@Override
public void onNegative(DialogInterface dialog) {
}
})
已下载
0