how to pick a time using material:1.3.0-alpha01, I am looking time picker following screenshot, which I found in material io.
I tried date picker is working
M
You can use the new MaterialTimePicker
introduced with the Material Components Library.
Note: this code requires at least the version 1.3.0-alpha03
.
import com.google.android.material.timepicker.MaterialTimePicker
val materialTimePicker = MaterialTimePicker.Builder()
.setTimeFormat(TimeFormat.CLOCK_24H)
.build()
materialTimePicker.addOnPositiveButtonClickListener {
val newHour: Int = materialTimePicker.hour
val newMinute: Int = materialTimePicker.minute
}
Using the same code with:
val materialTimePicker = MaterialTimePicker.Builder()
.setTimeFormat(TimeFormat.CLOCK_12H)
.build()
materialTimePicker.show(supportFragmentManager, "fragment_tag")