Search code examples
androidspinner

How to increase the clickable width of an Android spinner?


I have a Spinner which displays single digit numbers (1-6).

When I test on a phone, it's virtually impossible to click on a number because they are so narrow (font size is 12sp) and the only area which appears to be clickable is the text itself.

Ideally I'd like the user to be able click on a greater width on the Spinner drop down than just the text. I've tried padding with spaces but these are suppressed, and I've tried using PaddingLeft/Right but again there's no difference.

Here is the Spinner

<Spinner
            android:id="@+id/spinner_period1"
            android:layout_toRightOf="@id/spinner_weekday1"
            android:layout_below="@id/col1day"
            android:layout_height="wrap_content"
            android:prompt="@string/enterperiod"
            android:layout_width="80dp"
            android:entries="@array/periodlist"
            android:layout_marginRight="340dp"
            android:layout_marginBottom="20dip"
            />

Note that I also set the Spinner text attributes using:

<TextView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/textview"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"
        android:textSize="12sp"
        android:textColor="#768766"
        />

Any ideas? Thanks in advance

Mark


Solution

  • Try making the TextView wider in the android:layout_width attribute.

    <TextView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/textview"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:textSize="12sp"
            android:textColor="#768766"
            />
    

    That could possibly fix your issue or make it better at least.