如何在Android中更改微调器背景? [英] How to change the spinner background in Android?

查看:87
本文介绍了如何在Android中更改微调器背景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个需要更改微调器背景布局以匹配背景色的应用程序.我研究发现,我需要创建一个9补丁程序映像.我已经完成了创建9补丁程序图像并在应用程序中使用它,但它看起来比普通的微调框还大,而且我也看不到微调框中的下拉按钮.

I am developing an app in which I need to change the spinner background layout to match the background color. I researched and found that I need to create a 9 patch image. I have done creating the 9 patch image and used in the app but it looks bigger than the normal spinner and also I couldn't see the drop down button in the spinner as well.

如果你们从开始为Spinner创建9补丁程序映像并在应用程序中使用它开始,我很高兴为您提供清晰的教程.

I am so happy if you guys provide me a clear tutorial from start creating the 9 patch image for Spinner and using it in the app.

微调器代码

 <Spinner
        android:id="@+id/spnIncredientone"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/txtMixtureTitle" 
        android:layout_marginLeft="5dip"
        android:layout_marginRight="5dip"
        android:background="@drawable/spinner_background"
        android:prompt="@string/selectmixture" />

推荐答案

您可以像这样在xml中设置微调框的背景颜色:

You can set the spinners background color in xml like this:

android:background="YOUR_HEX_COLOR_CODE"

,如果您在微调器中使用下拉菜单,则可以如下设置其背景颜色:

and if you use the drop down menu with you spinner you can set its background color like this:

android:popupBackground="YOUR_HEX_COLOR_CODE"

这篇关于如何在Android中更改微调器背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆