如何增加微调框列表项的字体大小? [英] How should I increase the spinner list item font size?
本文介绍了如何增加微调框列表项的字体大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我的微调代码:
Spinner food = (Spinner) findViewById(R.id.spinner1);
ArrayAdapter<CharSequence> foodadapter = ArrayAdapter.createFromResource(
this, R.array.item_array, android.R.layout.simple_spinner_item);
foodadapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
food.setAdapter(foodadapter);
这是我创建微调器的布局文件的一部分:
This is a part of the layout file where I have created the spinner:
<Spinner
android:id="@+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/textView1" />
这是item_array
:
<resources>
<string name="item_picker">Select an iten</string>
<string-array name="item_array">
<item>Pizza</item>
<item>Burger</item>
<item>Sandwiches</item>
<item>Bread</item>
<item>Pastries</item>
<item>Snackers</item>
</string-array>
</resources>
注意:我不需要simple_spinner_dropdown_item
.
我只想增加列表项的大小.我该怎么办?
I just want to increase the size of the list items. How can I do that?
推荐答案
将以下xml作为spinner_layout.xml保存在布局文件夹中
Save the below xml as spinner_layout.xml in layout folder
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/spinnerTarget"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="13sp"
/>
更改所需的textSize. 并使用下面的适配器代码填充它.
change the textSize which you want. and use the below adapter code to fill it.
Spinner food = (Spinner) findViewById(R.id.spinner1);
ArrayAdapter<CharSequence> foodadapter = ArrayAdapter.createFromResource(
this, R.array.item_array, R.layout.spinner_layout);
foodadapter.setDropDownViewResource(R.layout.spinner_layout);
food.setAdapter(foodadapter);
这篇关于如何增加微调框列表项的字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文