如何在 Android 中更改微调器背景? [英] How to change the spinner background in 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 中设置 spinners 背景颜色:
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屋!