1

I'm having an hard time trying to fix this problem.

As you can see in those images, I want to make the dropdown list match its parent (that is the rectangular button) and, if it's possible, append the dropdown itself to the bottom of the Spinner.

Here's my XML.

The Spinner:

[...]

<Spinner
    android:id="@+id/fuel_types"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:padding="@dimen/padding_8dp"
    android:paddingLeft="@dimen/padding_5dp"
    android:layout_gravity="start"
    android:gravity="center"
    android:spinnerMode="dropdown"/>

[...]

Its TextView:

<?xml version="1.0" encoding="utf-8"?>
<TextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/single_item"
    style="@style/AppTheme.Dark.AddPrice"
    android:singleLine="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="@dimen/text_size_20sp"
    android:textStyle="bold"
    android:ellipsize="marquee"/>

The CheckedTextView:

<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1"
    style="@style/AppTheme.Dark.AddPrice"
    android:layout_width="match_parent"
    android:layout_height="@dimen/add_price_checked_height"
    android:ellipsize="marquee"
    android:paddingBottom="@dimen/padding_5dp"
    android:paddingLeft="@dimen/padding_10dp"
    android:paddingRight="@dimen/padding_10dp"
    android:paddingTop="@dimen/padding_5dp"
    android:singleLine="true"
    android:textColor="@color/white"
    android:textSize="@dimen/text_size_15sp"
    android:textStyle="bold"
    android:background="@color/colorPrimaryLight"
    android:gravity="center"
    android:textAlignment="gravity"/>

Now the current appearance of my Spinner:

Spinner 1 Spinner 2

This is what I'd like to obtain (maybe with the dropdown having rounded corners, too):

enter image description here

Any hints? Am I missing something?

Davide3i
  • 1,035
  • 3
  • 15
  • 35

1 Answers1

1

In addition to kris larson's comment, I can suggest to use this attribute on APIs older than 17:

android:dropDownVerticalOffset="@dimen/dropdown_vertical_offset"

Just create two different layout XMLs.

Davide3i
  • 1,035
  • 3
  • 15
  • 35