Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 463
Mark__C Avatar asked Jan 16 '23 20:01

Mark__C


2 Answers

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.

like image 70
prolink007 Avatar answered Feb 15 '23 20:02

prolink007


Try setting your TextView layout width to some arbitrary value rather than "wrap_content". That should make the whole thing clickable, as opposed to just the wrapped content.

like image 24
Barak Avatar answered Feb 15 '23 19:02

Barak