问题
Using a simple spinner. When I scroll the spinner the shadow around spinner dropdown starts growing darker in color.
I managed to fix the issue but
I will appreciate if someone could explain me why was this happening?
<Spinner
android:id="@id/drop_list_1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@android:color/transparent"
android:dropDownSelector="@android:drawable/list_selector_background"
android:dropDownWidth="wrap_content"
android:minHeight="@dimen/min_header_height"
android:popupBackground="#FFFFFF" />
回答1:
fixed: for Api below 21
style="@style/Widget.AppCompat.Spinner.DropDown"
if working on api 21 and above
android:popupTheme="@style/Widget.AppCompat.Spinner.DropDown"
回答2:
As of July 2016, the shadowing issue is still present when android:popupBackground
is used to specify a color (eg: White)
Google has provided a fix for this for Android 6.0 and above via android:popupTheme
but that is not applicable for < 6.0
Detailed explanation : How do I set a different theme for a Spinner's dropdown?
Working Solution (Android < 6.0) - Creating a shape and using it as background : Spinner graphical bug API 21
来源:https://stackoverflow.com/questions/35721120/changing-spinner-background-generates-dark-colored-border