I want to change a spinner's dropdown menu background color without changing the background color of the spinner itself (it's transparent). Is it possible?
Android spinner dropdown menu background color change
Asked Answered
Yep, it's possible. Use android:popupBackground
on the Spinner in your XML or setPopupBackgroundResource(int)
in code.
To change the background color of the drop-down list, add android:colorBackground
parameter to the theme in your styles.xml
Code:
<style name="AppTheme" parent="Theme.AppCompat.Light">
<item name="android:colorBackground">#ff0000</item>
</style>
Thus, the overall style is preserved: the effect when pressed, rounded corners, etc.
Screenshot:
When using Material Design 3 responsible attribute is:
<item name="colorSurface">@color/foo</item>
© 2022 - 2024 — McMap. All rights reserved.