Spinner: How to reduce the size of the counter

When I reduce the layout_width and layout_height from the spinner, the element name decreases. I want to reduce the size of the counter without affecting the names of the elements. How to do it?

+6
source share
1 answer

When creating an adapter for your Spinner, give a custom layout instead of a predefined

Create an 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 Size of the text, as well as the width and height of the elements in the spinner by changing this text box

Use it this way when creating an Adapter

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

The last task is ordinary

 spinner.setAdapter(adapter); 

Hope this helps you.

+8
source

All Articles