Search code examples
androidxamarin.androiddropdownandroid-spinner

Android spinner dropdown icon get hidden under background image


I am using Spinner in my android application where I use Spinner in a LinearLayout and I use Relative Layout with image background and LinerLayout inside FrameLayout to show the background image. In this case, my dropdown icon getting hidden behind the background image. Here my sample code.

<FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:background="#FFFF"
        android:layout_height="match_parent"
        android:id="@+id/mainLinearLayout">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="bottom"
        android:id="@android:id/background"
        android:background="@drawable/devbg"/>
    <LinearLayout
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:layout_height="match_parent"
        android:id="@+id/linearLayout1"> 
      <Spinner
            android:id="@+id/dropStatus"
            style="@style/Base.Widget.AppCompat.DropDownItem.Spinner"
            android:theme="@style/CardView.Dark"
            android:spinnerMode="dropdown"
            android:layout_width="180dp"
            android:layout_height="30dp"
            android:layout_marginBottom="7dp"
            android:layout_marginLeft="5dp"
            android:textSize="16dp"
            android:foregroundTint="#FF000000"
            android:backgroundTint="#FF000000"
            android:textAlignment="center"
            android:drawSelectorOnTop="true"/> 
   </LinearLayout>
</FrameLayout>

Solution

  • I do not know why you use RelativeLayout to set the background. Delete it and set the background in LinearLayout, everything would be okay.

    <FrameLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:background="#FFFF"
        android:layout_height="match_parent"
        android:id="@+id/mainLinearLayout">
    <LinearLayout
        android:minWidth="25px"
        android:minHeight="25px"
        android:layout_width="match_parent"
        android:orientation="vertical"
        android:layout_height="match_parent"
        android:id="@+id/linearLayout1"
        android:background="@drawable/pink"> 
      <Spinner
            android:id="@+id/dropStatus"
            style="@style/Base.Widget.AppCompat.DropDownItem.Spinner"
            android:theme="@style/CardView.Dark"
            android:spinnerMode="dropdown"
            android:layout_width="180dp"
            android:layout_height="30dp"
            android:layout_marginBottom="7dp"
            android:layout_marginLeft="5dp"
            android:textSize="16dp"
            android:foregroundTint="#FF000000"
            android:backgroundTint="#FF000000"
            android:textAlignment="center"
            android:drawSelectorOnTop="true"/> 
     </LinearLayout>
    </FrameLayout>
    

    enter image description here