Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5929745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:27:54+00:00 2026-05-22T14:27:54+00:00

I would like the spinner dropdown to open right below the spinner itself. E.g.:

  • 0

I would like the spinner dropdown to open right below the spinner itself.
E.g.:

enter image description here

How can i set the position of spinner dropdown?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:27:55+00:00Added an answer on May 22, 2026 at 2:27 pm

    You have to extend Spinner and change the location of AlertDialog (spinner when clicked acts as alertDialog).

    Code (does a bit more than just position, it also sets background for opened spinner):

    public class CustomSpinner extends Spinner {
    
    private AlertDialog mPopup;
    
    public CustomSpinner(Context context) {
        super(context);
    }
    
    public CustomSpinner(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    
    public CustomSpinner(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }
    
    @Override
    protected void onAttachedToWindow() {
        super.onAttachedToWindow();
    }
    
    @Override
    protected void onDetachedFromWindow() {
        super.onDetachedFromWindow();
    
        if (mPopup != null && mPopup.isShowing()) {
            mPopup.dismiss();
            mPopup = null;
        }
    }
    
    
    //when clicked alertDialog is made
    @Override
    public boolean performClick() {
        Context context = getContext();
    
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        CharSequence prompt = getPrompt();
        if (prompt != null) {
            builder.setTitle(prompt);
        }
    
    
    
        mPopup = builder.setSingleChoiceItems(
                new DropDownAdapter(getAdapter()),
                getSelectedItemPosition(), this).show();
    
        WindowManager.LayoutParams WMLP = mPopup.getWindow().getAttributes();
    
                //width and height must be set to anything other than WRAP_CONTENT!
        WMLP.x = 0; // x position
        WMLP.y = 50; // y position
        WMLP.height =390 ; //LayoutParams.WRAP_CONTEN
        WMLP.width = 315;
        WMLP.horizontalMargin = 0; 
        WMLP.verticalMargin = 0;
    
        mPopup.getWindow().setAttributes(WMLP);
    
    
    
        //ListView.getDefaultSize(size, measureSpec)
        ListView listView = mPopup.getListView();
        //listView.set
        // Remove divider between rows
        listView.setDivider(null);
    
        // Set custom background
        listView.setBackgroundResource(R.drawable.drop);
    
        // Remove background from all (grand)parent's
        ViewParent parent = listView.getParent();
        while (parent != null && parent instanceof View) {
            ((View) parent).setBackgroundDrawable(null);
    
            parent = parent.getParent();
        }
    
        return true;
    }
    
    @Override
    public void onClick(DialogInterface dialog, int which) {
        setSelection(which);
        dialog.dismiss();
        mPopup = null;
    }
    
    
     * <p>Wrapper class for an Adapter. Transforms the embedded Adapter instance
     * into a ListAdapter.</p>
     */
    private static class DropDownAdapter implements ListAdapter, SpinnerAdapter {
        private SpinnerAdapter mAdapter;
    
        /**
         * <p>Creates a new ListAddapter wrapper for the specified adapter.</p>
         *
         * @param adapter the Adapter to transform into a ListAdapter
         */
        public DropDownAdapter(SpinnerAdapter adapter) {
            this.mAdapter = adapter;
        }
    
        public int getCount() {
            return mAdapter == null ? 0 : mAdapter.getCount();
        }
    
        public Object getItem(int position) {
            return mAdapter == null ? null : mAdapter.getItem(position);
        }
    
        public long getItemId(int position) {
            return mAdapter == null ? -1 : mAdapter.getItemId(position);
        }
    
        public View getView(int position, View convertView, ViewGroup parent) {
            return getDropDownView(position, convertView, parent);
        }
    
        public View getDropDownView(int position, View convertView, ViewGroup parent) {
            return mAdapter == null ? null :
                    mAdapter.getDropDownView(position, convertView, parent);
        }
    
        public boolean hasStableIds() {
            return mAdapter != null && mAdapter.hasStableIds();
        }
    
        public void registerDataSetObserver(DataSetObserver observer) {
            if (mAdapter != null) {
                mAdapter.registerDataSetObserver(observer);
            }
        }
    
        public void unregisterDataSetObserver(DataSetObserver observer) {
            if (mAdapter != null) {
                mAdapter.unregisterDataSetObserver(observer);
            }
        }
    
        /**
         * <p>Always returns false.</p>
         *
         * @return false
         */
        public boolean areAllItemsEnabled() {
            return true;
        }
    
        /**
         * <p>Always returns false.</p>
         *
         * @return false
         */
        public boolean isEnabled(int position) {
            return true;
        }
    
        public int getItemViewType(int position) {
            return 0;
        }
    
        public int getViewTypeCount() {
            return 1;
        }
    
        public boolean isEmpty() {
            return getCount() == 0;
        }
    
       }
       }
    

    Then you just gotta insert it to your layout with “yourPackage.CustomSpinner” element like:

    <yourPackage.CustomSpinner 
         android:layout_height="wrap_content"
         android:id="@+id/spinner" 
         android:layout_width="fill_parent">
    </yourPackage.CustomSpinner>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to replicate the spinner effect that Spinrite displays in the upper-right
I would like to use a spinner. But, this code below does not display
i would like my spinner to be as in the picture.i can do it
Would like to be able to set colors of headings and such, different font
I have 3 spinners (dropdown menus). I would like the user to select item
I would like to have my spinner drop down just like a web form.
I would like to modify the spinner pop up dialog . I would like
I would like to create a customized popup dialog which contains a spinner. The
I have an Android Spinner view in my layout. I would like that spinner
I would like to take the value of a spinner and convert it to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.