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 8420107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:48:05+00:00 2026-06-10T02:48:05+00:00

i need these spinners to vertically center the text. i’ve tried stuff like this

  • 0

lol

i need these spinners to vertically center the text. i’ve tried stuff like this in the Spinner xml definition:

<Spinner
    android:id="@+id/dir_spn"
    android:layout_gravity="center_vertical"
    android:gravity="center_vertical"
    android:layout_weight="1"/>

i tried building a custom drop down layout:

<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    style="@style/SpinnerDropDownItem"
    android:singleLine="true"
    android:layout_width="match_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:ellipsize="marquee" />

styles.xml:

<resources>
<style name="SpinnerDropDownItem">
    <item name="android:gravity">center_vertical</item>
    <item name="android:layout_gravity">center_vertical</item>
    <item name="android:textColor">?android:attr/textColorPrimary</item>
    <item name="android:textColorHighlight">#FFFF9200</item>
    <item name="android:textColorHint">?android:attr/textColorHint</item>
    <item name="android:textColorLink">#5C5CFF</item>
    <item name="android:textSize">16sp</item>
    <item name="android:textStyle">normal</item>
</style>
</resources>

adapter dropdown set:

adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);

how do i get the Spinner text to center vertically?

EDIT:
it may be worth mentioning that the Activity is themed in the manifest thusly:

<resources>
<style name="SpeakNSpell" parent="@android:style/Theme">
    <item name="android:minHeight">68sp</item>
</style>
</resources>

which makes all Views at least 68sp high. is this affecting the text inside the Spinner as well?

  • 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-06-10T02:48:07+00:00Added an answer on June 10, 2026 at 2:48 am

    Rewrite

    You seem to want to center the text vertically in the item resource, shown below, but your code examples targets the dropdown menu…

    Compare Layouts

    The top Spinner is the default android simple_spinner_item layout and the bottom is the same but has android:gravity="center_vertical" added.

    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@android:id/text1"
        style="?android:attr/spinnerItemStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ellipsize="marquee"
        android:gravity="center_vertical"
        android:singleLine="true" />
    

    You can see that I used your Theme with the large minHeight. Here is a basic example to use this layout in an Adapter:

    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.spinner_item, list);
    // set whatever dropdown resource you want
    spinner.setAdapter(adapter);
    

    I went with the assumption that you want “CASH”, “Select Product”, etc from your picture centered, let me know if you where trying to do something else!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my android app I need to do something like this: I have 5
I'd like to write some tests for delete() in Grails. These need to be
I have a string like val1_val2,val3_val4 and I need to split these values to
I need to get an item's position in spinner knowing it's ID. I've tried
I m building an android application where I need these packages to import: import
i need to upload unique data from DB into spinner list in android.Ex.In my
I have a Spinner: Spinner country_list=new Spinner(this); ArrayAdapter<String> adapter= new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, countries); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
I have a number of scripts used to build a database. These need to
Need help on these 2 questions: If i am tracking a virtual pageview for
I need to remove these ' & ' characters from each property of a

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.