spinner dropdown start from top of spinner
In your spinner:
android:overlapAnchor="false"
NOTE If you are supporting API below 21, this attribute has to be copy and pasted as it is available for API >= 21.
You can to set this lines in your Spinner xml code:
android:spinnerMode="dropdown"android:dropDownVerticalOffset="50dp"
With this, your dropdownview will start with top offset. You can hardcode the offset number or calculate it at runtime and use:
setDropDownVerticalOffset(int pixels)
More in:Android Spinner
For me worked only when I created spinner style and added the "android:spinnerStyle" item to style of my theme.
I opened my /res/values/styles.xml
, found my theme ("AppTheme") and added <item name="android:spinnerStyle">@style/custom_spinner</item>
like this:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="android:spinnerStyle">@style/custom_spinner</item></style><style name="custom_spinner" parent="@android:style/Widget.Holo.Light.Spinner"></style>