Search code examples
androidandroid-layoutandroid-5.0-lollipopandroid-dialogfragmentandroid-timepicker

Android TimePicker - hour line is not align to center


I used Android TimePicker in my custom dialog.
The hours line is not align to center.
As you see the xml is look ok for center controller.
Is it possible at all to change the timepicker properties from custom dialog and not from FragmentDialog? How should i center it?

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_gravity="center"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:gravity="center"
        android:minHeight="50dp"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/titleDateAndTime"
            android:layout_width="wrap_content"
            android:layout_height="25dp"
            android:layout_gravity="center"
            android:gravity="center"
            android:text="Today"/>

        <ImageView
            android:id="@+id/changeDateAndTimeState"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginLeft="10dp"
            android:src="@drawable/arrow"/>

    </LinearLayout>

<TimePicker
    android:id="@+id/time_picker"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"/>

<Button
    android:id="@+id/date_time_set"
    style="@style/Button.Buttons"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/ripple_or_holo"
    android:text="@string/call_reminder_set_button"/>

Custom dialog screenshot


Solution

  • The option to center each of the element inside the TimePicker is not supported.
    My last resort was to make custom view for the time picker with my layout.