Bug 41198 - TimePicker orientation not responsive in custom renderer
Summary: TimePicker orientation not responsive in custom renderer
Alias: None
Product: Forms
Classification: Xamarin
Component: Android ()
Version: 2.3.2
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-05-20 02:53 UTC by Gerard C
Modified: 2016-11-07 22:32 UTC (History)
4 users (show)

Tags: ac
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 41198 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Gerard C 2016-05-20 02:53:30 UTC
Using the OOB Xamarin.Forms.TimePicker you will notice on Android that the TimePicker layout is dynamically responsive to portrait vs. landscape orientation changes. If you wrap it in a custom ViewRenderer that responsive layout no longer functions. In the custom Renderer, the best I can do is "new up" another TimePickerDialog on each EditText click which will display the TimePicker appropriately for the current orientation but the picker is not responsive for changes from landscape to portrait or vice versa.

Custom Renderer:
using Android.App;
using Android.Widget;
using MyNamespace.Renderers;
using System;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;

[assembly: ExportRenderer(typeof(DurationPicker), typeof(DurationPickerRenderer))]
namespace MyNamespace.Droid.Renderers
public class DurationPickerRenderer : ViewRenderer<Xamarin.Forms.TimePicker, EditText>, TimePickerDialog.IOnTimeSetListener
    TimePickerDialog dialog = null;
    EditText editText;

    protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.TimePicker> e)

        if (null == Control)
            editText = new EditText(Forms.Context)

            // My Humanized text
            editText.Text = (this.Element as DurationPicker).DurationText;
            editText.KeyListener = null;

        if (null != e.OldElement)
            editText.Click -= Control_Click;
            editText.FocusChange -= Control_FocusChange;

        if (null != e.NewElement)
            editText.Click += Control_Click;
            editText.FocusChange += Control_FocusChange;

    void Control_FocusChange(object sender, Android.Views.View.FocusChangeEventArgs e)
        if (e.HasFocus)

    void Control_Click(object sender, EventArgs e)

    private void ShowTimePicker()
        // Displays in current orientation and remains in current orientation
        // regardless of subsequent clicks or orientation changes
        //if (null == dialog)
        //    dialog =  new TimePickerDialog(Context, this, this.Element.Time.Hours, this.Element.Time.Minutes, true);

        // Displays in current orientation every click but layout is not 
        // responsive to subsequent orientation changes
        new TimePickerDialog(Context, this, this.Element.Time.Hours, this.Element.Time.Minutes, true)

    public void OnTimeSet(Android.Widget.TimePicker view, int hourOfDay, int minute)
        var time = new TimeSpan(hourOfDay, minute, 0);

        this.Element.SetValue(DurationPicker.TimeProperty, time);
        // My Humanized text
        this.Control.Text = (this.Element as DurationPicker).DurationText;
Comment 1 Gerard C 2016-05-20 12:43:42 UTC
The responsive effect on the OOB Xamarin.Forms.TimePicker is visible on Android Lollipop v5.x or higher.
Comment 2 Rui Marinho 2016-08-09 14:15:08 UTC
Hi please take a look at DatePicker we fixed this issue there , seems we need to port that fix to TimePicker too.

Basically we recreate the dialog on orientation changes. 


You could make a PR with that fix too if you have time.
Comment 3 adrianknight89 2016-11-06 03:24:39 UTC
For me, this works on AppCompat / API 23.