Search code examples
androiduser-interfacedrop-down-menuspinnerdropdown

Android margin popup drodown spinner


I would like something like that :

wantedSituation

but I have this result for now : CurrentSituation

Indeed there is 1 problem, I want to apply a margin top de dropdown popup. I tried 1 thing for that which didn't work : popupTheme There is my spinner :

<androidx.appcompat.widget.AppCompatSpinner
                android:popupBackground="@color/bgChoicesSpinner"
                android:popupTheme="@style/popupOverlay"
                android:dropDownWidth="match_parent"
                android:layout_marginTop="30dp"
                android:layout_marginStart="5dp"
                android:id="@+id/spinnerCountry"
                android:layout_width="match_parent"
                android:layout_height="50dp">

There is my style :

<style name="popupOverlay" parent="ThemeOverlay.AppCompat.Light">
        <item name="android:layout_marginTop">10dp</item>
        <item name="android:background">@color/bgChoicesSpinner</item>
    </style>

Solution

  • Use the android:dropDownVerticalOffset="xxdp" attribute.

       <androidx.appcompat.widget.AppCompatSpinner
            android:spinnerMode="dropdown"
            android:dropDownVerticalOffset="40dp"
            ...
            />
    

    enter image description here