Search code examples
androidandroid-layoutandroid-spinner

Android bottom navigation bar overlapping Spinner. Set Spinner dropdown height / margin


There is an interesting issue I stumbled upon while working on an Android Honeycomb project. As you can see in the image below, while expanding a Spinner in a dialog, the navigation bar at the bottom overlaps it. Thus, the element at the bottom can not be selected.

In order to fix this I tried using android:fitsSystemWindows="true" in the Spinner widget. It did not work. Also I noticed that we have an XML Attribute for dropdown width, android:dropDownWidth, but none for height.

Navigation Bar overlapping Spinner

Here is the XMl layout for the 3 Spinners:

    <TableRow>

        <Spinner
            android:id="@+id/order_dialog_category_code_Spinner"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:fitsSystemWindows="true" />

        <Spinner
            android:id="@+id/order_dialog_packing_code_Spinner"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:fitsSystemWindows="true" />

        <Spinner
            android:id="@+id/order_dialog_product_Spinner"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:fitsSystemWindows="true" />
    </TableRow>

I will keep testing and hope to find a solution soon but it is an interesting issue and it deserved to be posted.

I did not test in Android ICS yet but I think it might act the same.

EDIT

I managed somewhat of a fix by using the android:layout_marginBottom attribute for the Spinners. It did solve the issue but now I have the margin in the dialog view as well and I don't want that.

Spinner overlapping temporary fix

Does anyone know how to set the margin only for the dropdown resource?


Solution

  • After some more research it seems that you can not manipulate the height of the Spinner dropdown, or any other of it's layout attributes.

    This is because the dropdown is actually a popup dialog that cannot be accesed from the Spinner View.

    This answer states it clear: https://stackoverflow.com/a/1918655/529138

    So it seams that I have to use android:layout_marginBottom as specified in the question.