Is it possible to change the style of an Android L TimePickerDialog?

I was testing my app on an Android L emulator, and I noticed that the TimePickerDialog has significantly changed to this:

Android L TimePickerDialog

  • How to invoke default deserialize with gson
  • Android: onSaveInstanceState not being called from activity
  • How to be notified when a peer is no longer available in the Wi-Fi Direct range?
  • Android calendar view
  • Android: Disable highlighting in GridView
  • 'Unsupported template dependency: Upgrade your Android Eclipse plugin' with SDK Tools v22
  • This doesn’t fit with the theme of my app, and I wanted to know if it is possible to get the old TimePickerDialog style when running on Android L.

  • Android: how to create a background from pattern?
  • How to listen for state change in SwitchCompat widget?
  • Enable rear camera with HTML5
  • AlarmManager, BroadcastReceiver and Service not working
  • Error:Jack is required to support java 8 language features
  • Error:Execution failed for task ':app:processDebugResources'. > java.io.IOException: Could not delete folder “” in android studio
  • 3 Solutions collect form web for “Is it possible to change the style of an Android L TimePickerDialog?”

    You can use the TimePickerDialog constructor with theme parameter to specify the theme.

    TimePickerDialog(Context context, 
                     int theme, 
                     TimePickerDialog.OnTimeSetListener callBack, 
                     int hourOfDay, 
                     int minute, 
                     boolean is24HourView)
    

    Add android:timePickerMode=”spinner” to the XML

        <TimePicker
            android:id="@+id/timePicker1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:timePickerMode="spinner">
        </TimePicker>
    

    https://developer.android.com/reference/android/R.attr.html#timePickerMode

    You can choose between spinner or clock modes. This attribute is only available from API level 21, before that the spinner mode was the only option available.

    If you want the AM / PM to be a picker instead of a button then I recommend you use the single parameter constructor with a ContextThemeWrapper:

    new TimePicker(new ContextThemeWrapper(getActivity(), android.R.style.Theme_Holo_Light_Dialog_NoActionBar));
    

    AM-PM picker

    If you pass the theme into the multiple parameter constructor then you’ll end up with a rather ugly AM / PM button, and the colon will be missing between the hour and minute columns.

    new TimePicker(getActivity(), null, TimePickerDialog.THEME_HOLO_LIGHT);
    

    AM-PM button

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.