Android设置TimePicker样式和字体颜色

Android默认的TimePicker有两种,一种为clock样式,一种为Spinner样式
所以设置TimePicker可以使用
android:timePickerMode=“spinner”
这个时候字体为黑色的 如果想变成白色字体和可滑动更改的样式,就需要设置字体样式

<style name="Theme.picker" parent="android:Theme.Holo.Light">
        <item name="android:editTextStyle">@style/Widget.EditText.White</item>
    </style>
    <style name="Widget.EditText.White" parent="@android:style/Widget.EditText">
        <item name="android:textColor">@color/normal</item>
    </style>

3.xml文件中的应用

 <TimePicker
        android:id="@+id/timer_picker"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="@dimen/dp_20"
        android:layout_marginRight="@dimen/dp_20"
        android:timePickerMode="spinner"
        android:theme="@style/Theme.picker"
        android:focusable="false"
        />
发布了262 篇原创文章 · 获赞 2 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/baidu_41666295/article/details/105706124
今日推荐