54545

Spinner tab size

Question:

I have spinner on my app and I want to make the spaces between each line larger. I have already tried android:TextSize:"30sp" with no luck any ideas?

Answer1:

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

Create xml named spinner_row.xml (Any name of your choice) in res/layout folder

<?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="32sp" android:layout_height="36dp" android:gravity="left|center_vertical"/>

Here you can change the color Text size and width ,height and spacing by setitng the margin and padding 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.

<hr />

second way,

create a style like this withe attributes of your choice, like test size, padding etc And your style should have a parent parent="@android:style/Widget.TextView.SpinnerItem" as shown in the below style

<style name="spinnerStyleView" parent="@android:style/Widget.TextView.SpinnerItem"> <item name="android:background"> @drawable/notetvbg</item> <item name="android:textColor">@android:color/darker_gray</item> </style>

And apply style to your spinner by using style attribue

style="@style/spinnerStyleView"

Answer2:

If you are using an ArrayAdapter to provide items for the spinner, you would've specified a resource file for the drop down view, maybe android.R.layout.simple_spinner_dropdown_item ?

You could create your own drop down resource and set the height to whatever you want, then pass that to the adapter instead of android.R.layout.simple_spinner_dropdown_item

Recommend

  • How to convert NAnt function “path::combine(path1, path2)” to MSBuild?
  • Savon soap body problem
  • Why does .addView throw this parent/child exception?
  • Loop animation drawable
  • How to Handle Click on Imageview in Custom Listview with image and Textview?
  • Gray line inside cardview :)?
  • Null ImageView Reference
  • Wrapping text in spinner android
  • Running jasmine tests for a component with NgZone dependency
  • How to resolve permission denied maybe missing internet permission?
  • Splash Screen will not display
  • WPF Template Binding in ToggleButton UserControl
  • JBoss External Properties Files in Classpath
  • Android - Material Design - NavigationView - How to put vertical scroll?
  • Bad request using file_get_contents for PUT request in PHP
  • When to use `image` and when to use `Matrix` in Emgu CV?
  • Pass value from viewmodel to script in zk
  • Uncaught Error: Could not find module `ember-load-initializers`
  • SSO with signing and signature validation doesn't work
  • Deserializing XML into class C#
  • bootstrap to use multiple ng-app
  • Cannot Parse HTML Data Using Android / JSOUP
  • How to get icons for entities from eclipse?
  • How to delete a row from a dynamic generate table using jquery?
  • How to include full .NET prerequisite for Wix Burn installer
  • json Serialization in asp
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • How to stop GridView from loading again when I press back button?
  • Turn off referential integrity in Derby? is it possible?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • JaxB to read class hierarchy
  • Easiest way to encapsulate a HTML5 webpage into an android app?
  • Busy indicator not showing up in wpf window [duplicate]
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • How to Embed XSL into XML
  • UserPrincipal.Current returns apppool on IIS
  • Conditional In-Line CSS for IE and Others?
  • java string with new operator and a literal
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize