3alto
3alto

Reputation: 189

getting the Material Design TimePicker - android?

if i use TimePicker/TimePickerDialog in my app i'm getting timePickerMode="spinner" styled widget though what i'm looking for is timePickerMode="clock". this is the style I've done

<style name="timePicker_dialog parent="android:Theme.Material.Light">
<item name="timePickerMode">clock</item>
</style>

and I've set this res as the style in the TimePicker via it's TimePickerDialog(), butt i'm still getting the spinner. is it device dependent? my phone is running v4.4.4? if not, what am i missing here. thanks!

Upvotes: 1

Views: 2647

Answers (2)

Idan
Idan

Reputation: 137

As of late 2020, MaterialTimePicker is in the beta version of the Material package.
Therefore you can add the following to your app Gradle:

dependencies { ...
     implementation 'com.google.android.material:material:1.3.0-beta01'
}

And then use MaterialTimePicker like so:

      MaterialTimePicker materialTimePicker = new MaterialTimePicker.Builder()
          .setTimeFormat(clockFormat)
          .setHour(hour)
          .setMinute(minute)
          .build();

      materialTimePicker.show(requireFragmentManager(), "fragment_tag");

Upvotes: 2

kai hello
kai hello

Reputation: 145

Try add dependencies compile 'com.android.support:appcompat-v7:23.1.0' i think use appcompat's theme under 5.0 parent="Theme.AppCompat.Light"

Upvotes: 0

Related Questions