Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spinner: How to reduce size of spinner

Tags:

android

When I am reducing layout_width and layout_height of spinner the item name gets cut. I want to decrease the size of the spinner without affecting the item names.How to do it?

like image 816
Surabhi Pandey Avatar asked Feb 18 '13 11:02

Surabhi Pandey


1 Answers

While Creating Adapter for your Spinner give custom layout instead of predefined one

Create xml named spinner_row.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
 android:id="@+id/cust_view"  
    android:layout_width="match_parent" 
    android:textColor="@color/black"
    android:textSize="12dp"
    android:layout_height="36dp" 
    android:gravity="left|center_vertical"/> 

Here you can change the color Text size and width and height of the Elements in the spinner by modifying this textview

Use it like this while creating Adapter

 ArrayAdapter<String> adapter=new ArrayAdapter<String>(context, R.layout.spinner_row,yourlist);

The Last task is routine

spinner.setAdapter(adapter);

I hope this will help you.

like image 140
Pragnani Avatar answered Nov 05 '22 16:11

Pragnani