10

I'm trying to build a TimePickerDialog but unfortunately the Time Picker that comes up is extremely cumbersome to Use :

enter image description here

Is there any way to build a timepicker like the old ones that Android use to have like below :

enter image description here

My code is as follows :

    ButtonTime.Click += delegate
    {
        ShowTimePickerDialog();
    };

    void ShowTimePickerDialog()
    {
        var dialog = new TimePickerDialogFragment(this, hour, minute, this);

        dialog.Show(FragmentManager, null);
    }

3 Answers3

7

adding new xml style

<?xml version="1.0" encoding="utf-8" ?>
<resources>
  <style name="SpinnerTimePicker" parent="android:Widget.Material.Light.TimePicker">
    <item name="android:timePickerMode">spinner</item>
  </style>

  <style name="ClockTimePicker" parent="android:Widget.Material.Light.TimePicker">
    <item name="android:timePickerMode">clock</item>
  </style>
</resources>

than set the timepicker style to SpinnerTimePicker in MainTheme

 <item name="android:timePickerStyle">@style/SpinnerTimePicker</item>
Abdullah Tahan
  • 1,963
  • 17
  • 28
1

I would say use the Holo theme. I refer to following link on stackoverflow which you might find usefull.

Community
  • 1
  • 1
Simon
  • 1,691
  • 2
  • 13
  • 28
  • Nice that did it. I'm using the holo theme. –  Jan 04 '16 at 17:52
  • Now quick question how can I set the timepickermode programmatically in a timepickerdialog –  Jan 04 '16 at 17:56
  • You could achieve this by passing a defStyleRes or maybe a defStyleAttr when you create your time picker. – Simon Jan 04 '16 at 18:02
1

android:timePickerMode Defines the look of the widget. Prior to the L release, the only choice was spinner. As of L, with the Material theme selected, the default layout is clock, but this attribute can be used to force spinner to be used instead.

Must be one of the following constant values.

Constant Value Description clock 2 Time picker with clock face to select the time. spinner 1 Time picker with spinner controls to select the time.

from Documentaion

https://developer.android.com/reference/android/widget/TimePicker.html#attr_android:timePickerMode

MarGin
  • 2,078
  • 1
  • 17
  • 28