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?
问题:
回答1:
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.
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"
回答2:
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