Android-xml中更改Spinner 的下拉箭头颜色和列表背景色

解决方案

1、通过代码实现

在xml中,确保微调器有一个ID,假设ID为”spinner“ 的微调器,在代码中,在onCreate() 中添加一下内容:
Spinner spinner = (Spinner) findViewById(R.id.spinner);
spinner.getBackground().setColorFilter(getResources().getColor(R.color.red), PorterDuff.Mode.SRC_ATOP);

但此方法,虽然实现了下拉箭头颜色的变化,但是会在点击下拉箭头后取消,箭头颜色回复原本颜色。

2、通过spinner 控件的xml实现下拉控件和背景设

对于API 21+:
android:backgroundTint 《表示下拉箭头的颜色设置》
android:popupBackground《表示spinner控件下拉菜单出来的背景颜色》
<Spinner
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:backgroundTint="@color/red" 
    android:popupBackground="@color/red"/>

或者,如果是使用的支持库,

<android.support.v7.widget.AppCompatSpinner
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:backgroundTint="@color/red"
    app:popupBackground="@color/red" />

3

android-在XML中更改Spinner下拉箭头的颜色
https://www.itranslater.com/qa/details/2582805979217789952

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值