2

代码:

<NumberPicker
        android:id="@+id/numer_picker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        />

它正在服用black color by default。我该如何改变呢?

4

4 回答 4

2

解决方案:

<NumberPicker
        android:id="@+id/numer_picker"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="50dp"
        android:solidColor="#2E1E91" />

利用

android:solidColor="#your_color"

更改默认颜色。

于 2020-01-17T08:32:57.317 回答
2

试试这 2 件事:

尝试更改背景颜色:

android:background="#EEEEEE"

或使用solidColor 对其进行样式设置:

android:solidColor="#EEEEEE"
于 2020-01-17T09:31:19.207 回答
1

使用颜色更改数字选择器的背景,或者您可以通过 drawable 使用多种颜色。

用于单一背景颜色

  android:background="@color/colorAccent"

并用于渐变或时尚背景

  android:background="@drawable/background_change"

和 background_change.xml 文件是

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
 <gradient
    android:startColor="#707070"
    android:centerColor="#f8f8f8"
    android:endColor="#707070"
    android:angle="270"/>
</shape>
于 2020-01-17T08:41:22.807 回答
0

使用下面将默认颜色更改为您想要的任何颜色,

android:background="your color here"

例子:android:background="#71BF45 "

于 2020-01-17T08:38:35.047 回答