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

只谈情不闲聊 提交于 2019-12-23 16:48:10

问题


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.

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.

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


回答1:


Even i faced the same issue. Unlike your screen my screen has just one option. so i made a fix changing the android:spinnerMode:"dialog".

<Spinner
        android:id="@+id/dialog_spinner"
        android:spinnerMode="dialog"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
       >

This would show your list in a new dialog. Just in case might be helpful for people searching with similar problem.




回答2:


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.



来源:https://stackoverflow.com/questions/10074867/android-bottom-navigation-bar-overlapping-spinner-set-spinner-dropdown-height

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!