有三种方法可以实现这一点。
1.通过代码:
在你的XML中,确保你的微调有一个ID。 比方说,我们有一个微调ID为“微调”。
在你的代码中,在你的onCreate()中添加以下内容:
Spinner spinner = (Spinner) findViewById(R.id.spinner); spinner.getBackground().setColorFilter(getResources().getColor(R.color.red), PorterDuff.Mode.SRC_ATOP);
其中红色是您在values文件夹中的colors.xml中定义的颜色。
2.通过xml:
对于API 21+:
或者如果您使用支持库,则可以使用:
3.通过drawables:
你可以使用这个在线工具: http : //android-holo-colors.com
这将使用您喜欢的颜色为任何视图生成自定义绘图。 确保你select微调,然后下载资源。