skydoves / PowerSpinner

🌀 A lightweight dropdown popup spinner, fully customizable with an arrow and animations for Android.
Apache License 2.0
1.2k stars 114 forks source link

Width is 0 #29

Closed sudansh closed 4 years ago

sudansh commented 4 years ago

Please complete the following information:

Describe the Bug:

The dropdown menu isn't showing on click of the powerspinner. On debugging I found out the width of the view is 0. If I use spinner_popup_width with some value the dropdown shows.

Expected Behavior: The dropdown should show

Doesn't Work

<com.skydoves.powerspinner.PowerSpinnerView
                        android:id="@+id/powerspinner"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginHorizontal="@dimen/space.medium"
                        android:layout_marginTop="@dimen/space.small"
                        android:background="@drawable/text_display_border"
                        android:backgroundTint="#2E5BFF"
                        android:gravity="start"
                        android:hint="@string/hint"
                        android:padding="@dimen/space.medium"
                        android:textColor="#57779e"
                        app:spinner_arrow_drawable="@drawable/ic_dropdown"
                        app:spinner_divider_color="#80A5A1DC"
                        app:spinner_divider_show="true"
                        app:spinner_popup_animation="dropdown"
                        app:spinner_popup_background="@color/white" />

Works


 <com.skydoves.powerspinner.PowerSpinnerView
                        android:id="@+id/powerspinner"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginHorizontal="@dimen/space.medium"
                        android:layout_marginTop="@dimen/space.small"
                        android:background="@drawable/text_display_border"
                        android:backgroundTint="#2E5BFF"
                        android:gravity="start"
                        android:hint="@string/select_asset_id"
                        android:padding="@dimen/space.medium"
                        android:textColor="#57779e"
                        app:spinner_arrow_drawable="@drawable/ic_dropdown"
                        app:spinner_divider_color="#80A5A1DC"
                        app:spinner_divider_show="true"
                        app:spinner_popup_animation="dropdown"
                        app:spinner_popup_background="@color/white"
                        app:spinner_popup_width="100dp" />
skydoves commented 4 years ago

Hi, @sudansh. The width of the popup is determined by the width size of the PowerSpinnerView. So I think If your parent view's width size is 0 or changed from 0, then the width of the popup could be 0. Could you build using this demo project?

sudansh commented 4 years ago

@skydoves Thanks for the information. I have my view as gone and then making it visible. Making it from invisible to visible showed the dropdown. I have fixed it by setting the adapter after it is visible.