微调使用按钮样式的机器人改变外观 [英] android change appearance of Spinner Button using styles

查看:140
本文介绍了微调使用按钮样式的机器人改变外观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图改变我的微调按钮的样式(不是物品!)。不知怎的,它并没有得到应用:

i tried to change the style of my spinner button (not the items!). Somehow it does not get applied:

 <style name="myStyle"  parent="@android:style/Widget.TextView.SpinnerItem">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">50dip</item>
    <item name="android:textAppearance">?android:attr/textAppearanceSmall</item>
    <item name="android:textStyle">italic</item>
 </style>

<Spinner 
     android:id="@+id/widget_type_spinner"
     style="@style/myStyle"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"/>

,如果我定义这个在我的主题,它的工作就像一个迷人的另一面:

on the other side if I define this in my theme it worked like a charme:

<style name="Standard" parent="android:style/Theme.Black">
    <item name="android:spinnerItemStyle">@style/myStyle</item> 
</style>

但我不希望所有的微调这种行为... 有任何想法吗?

But I don't want this behavior for all spinner ... Any ideas?

推荐答案

我觉得你可以做这样的事情:

I think you can do something like this:

的onCreate()

In onCreate()

Spinner spinner = (Spinner) findViewById(R.id.widget_type_spinner);
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<String>(this, R.layout.my_spinner,getResources().getStringArray(R.array.array_of_strings));
spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(categorySpinnerAdapter);

在布局(在你的布局文件夹)

In your layout (inside your layout folder)

<Spinner 
 android:id="@+id/widget_type_spinner"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"/>

my_spinner.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/textview_spinner"
    android:layout_width="wrap_content"
    android:layout_height="50dip"
    android:textAppearance="@android:style/TextAppearance.Small"
    android:textStyle="italic" >
</TextView>

这篇关于微调使用按钮样式的机器人改变外观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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