[android] How to change the spinner background in Android?

It is already said in other answers . I did it like placing Spinner inside a CardView and changed the cardBackgroundColor . You could use some other views also and set its background either drawable or color . Thus it doesn't affect Spinner drop down arrow. As the spinner dropdown arrow disappears if we set background to Spinner.

 <androidx.cardview.widget.CardView
        android:id="@+id/cardView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:cardCornerRadius="6dp"
        app:cardBackgroundColor="@color/white">
        
        <Spinner
            android:id="@+id/spinner"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:padding="10dp"/>

    </androidx.cardview.widget.CardView>