0

如何更改数字选择器项目(数字、文本)的颜色?

我尝试使用 styles.xml 文件更改颜色,但没有成功

样式.xml:

<?xml version="1.0" encoding="utf-8"?>
 <resources xmlns:android="http://schemas.android.com/apk/res/android">
 <style name="NumberPickerText">
    <item name="android:textSize">20dp</item>
    <item name="android:textColor">@color/white</item>
 </style>
 </resources>

main_activity.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  android:id="@+id/parentLayout_homesearch"
  android:layout_width="match_parent"
  android:layout_height="fill_parent"
  android:background="@color/white"
  android:orientation="vertical">
 <NumberPicker
 android:theme="@style/NumberPickerText"
 android:id="@+id/numberPicker1"
 android:layout_width="150dp"
 android:layout_height="wrap_content"
 android:layout_alignParentStart="true" />
</LinearLayout>
4

0 回答 0