微调文字的大小没有改变? [英] Spinner text size does not change?

查看:96
本文介绍了微调文字的大小没有改变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法改变微调的TEXTSIZE或颜色与$ C $低于C:

I could not change spinner's textsize or colour with the code below:

<Spinner 
    android:id="@+id/spinner1"
    style="@style/submitspinner"
    android:layout_weight="2"
    android:entries="@array/a_code"
    android:prompt="@string/p_code" />

风格:

<style name="submitspinner" parent="@android:TextAppearance.Widget.TextView.SpinnerItem">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">match_parent</item>
    <item name="android:layout_margin">10sp</item> 
    <item name="android:textColor">@android:color/holo_blue_dark</item>
    <item name="android:textSize">@dimen/pt</item> 
</style>

看起来一样的,我怎么能提高微调的TEXTSIZE和改变颜色?

It looks same, how can I increase textsize and change colour of the spinner?

推荐答案

你应该做的定制纱厂是创建一个单独的XML,将作为您的模板字符串中的微调,像这样:

What you should do for custom Spinners is create a single XML that will act as your template for the string in the Spinner, like so:

<?xml version="1.0" encoding="UTF-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
   android:id="@+id/standard_spinner_format"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:textSize="@dimen/pt"
   android:textColor="@android:color/holo_blue_dark"/>

然后,当你在Java中创建微调适配器执行以下操作:

Then when you create your Spinner adapter in java do the following:

ArrayAdapter<CharSequence> typeAdapter = ArrayAdapter.createFromResource(getActivity(), 
          R.array.my_spinner_array, R.layout.custom_xml_spinner_layout); //change the last argument here to your xml above.
    typeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

这篇关于微调文字的大小没有改变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆