Android TimePicker - 小时线未与中心对齐
Android TimePicker - hour line is not align to center
我在自定义对话框中使用了 Android TimePicker。
小时线未对齐中心。
如您所见,xml 适合中央控制器。
是否可以从自定义对话框而不是 FragmentDialog 更改时间选择器属性?我应该如何居中?
<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"/>
https://developer.android.com/reference/android/widget/TimePicker.html:
如果你看这里你不会找到这样的方法或参数。
此外,如果您发现设置此值的错误,根据我的经验,我真的不建议使用某些默认行为。因为 TimePicker 有很多不同的实现。
使用默认行为或什么都不做。
我唯一的解决办法:就是用numberpicker等自己写timepicker
不支持将 TimePicker
内的每个元素居中的选项。
我最后的办法是使用我的布局为时间选择器制作自定义视图。
我在自定义对话框中使用了 Android TimePicker。
小时线未对齐中心。
如您所见,xml 适合中央控制器。
是否可以从自定义对话框而不是 FragmentDialog 更改时间选择器属性?我应该如何居中?
<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"/>
https://developer.android.com/reference/android/widget/TimePicker.html: 如果你看这里你不会找到这样的方法或参数。
此外,如果您发现设置此值的错误,根据我的经验,我真的不建议使用某些默认行为。因为 TimePicker 有很多不同的实现。 使用默认行为或什么都不做。
我唯一的解决办法:就是用numberpicker等自己写timepicker
不支持将 TimePicker
内的每个元素居中的选项。
我最后的办法是使用我的布局为时间选择器制作自定义视图。