你如何使用自定义Datepicker和Timepicker皮肤?

her*_*rmy 6 user-interface android datepicker timepicker

我想为我的Datepickers和Timepickers使用自定义皮肤.在XML中更改背景并不起作用(它将背景更改为集合,而不是每个按钮).API很简短,没有外观(http://developer.android.com/reference/android/widget/DatePicker.html).是否可以为Datepickers和Timepickers的按钮使用自定义皮肤?

Bha*_*ara 12

好的,你正在为datepicker和时间选择器寻找自定义主题..这将允许你改变按钮的主题..

https://github.com/luminousman/DatePicker

并以ICS风格

https://github.com/luminousman/android-datepicker

希望对你有帮助....


bio*_*bnA 4

不幸的是,numberpicker 是一个内部小部件。需要覆盖这些背景。并且没有官方的方法可以做到这一点。

res/layout/number_picker.xml

<NumberPickerButton android:id="@+id/increment"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/timepicker_up_btn" />

<EditText android:id="@+id/timepicker_input"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:singleLine="true"
    style="?android:attr/textAppearanceLargeInverse"
    android:textColor="@android:color/primary_text_light"
    android:textSize="30sp"
    android:background="@drawable/timepicker_input" />

<NumberPickerButton android:id="@+id/decrement"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/timepicker_down_btn" />
Run Code Online (Sandbox Code Playgroud)