[英]How to change background color of number picker in android
代碼:
<NumberPicker
android:id="@+id/numer_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
它black color by default
采用black color by default
。 我怎樣才能改變它?
解決方案:
<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"
更改默認顏色。
試試這 2 件事:
要么嘗試更改背景顏色:
android:background="#EEEEEE"
或者使用 solidColor 對其進行樣式設置:
android:solidColor="#EEEEEE"
使用顏色更改數字選擇器的背景,或者您可以通過 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>
使用下面將默認顏色更改為您想要的任何顏色,
android:background="your color here"
示例: android:background="#71BF45 "
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.