Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
854 views
in Technique[技术] by (71.8m points)

android - Spinner popup background color issue

The following code produces an issue (see attached images) on Asus Intel Zenfone. Every other device I tested on is showing it fine, meaning the black area around the Spinner popup is transparent.

Any way to get rid of black color? I have Theme.AppCompat.Light.NoActionBar applied to the Activity.

<android.support.v7.widget.AppCompatSpinner
    android:id="@+id/spinner"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    android:popupBackground="@color/light_primary" />

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I face the same problem,finally i got solution.You need to create one xml file in drawable folder.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >
    <corners android:radius="2dp" />
    <solid android:color="#606d73" />
</shape>

and then apply it to the spinner:

<Spinner
 android:id="@+id/from_spinner"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:background="@drawable/refine_drpdn_right"
 android:drawSelectorOnTop="true"
 android:popupBackground="@drawable/spinner_popup_background"
 android:spinnerMode="dropdown" />

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...