简体   繁体   English

自定义微调器具有白色文本颜色

[英]Custom Spinner with white text color

I want my Action Bar spinner to display it's text in white (like in google maps app), but i'm struggling to get there.. 我希望我的Action Bar微调器以白色显示它的文本(就像谷歌地图应用程序一样),但我很难到达那里。

i'm trying something like this: 我正在尝试这样的事情:

   <style name="Mepo.Spinner" parent="@android:style/Widget.Spinner">
   <item name="android:spinnerItemStyle">@style/StandardSpinnerItem</item>  
   <item name="spinnerItemStyle">@style/StandardSpinnerItem</item>
   </style>

  <style name="StandardSpinnerItem" parent="@android:style/Widget.TextView.SpinnerItem">
  <item name="android:textAppearance">@android:color/white</item>
  <item name="android:textColor">@android:color/white</item>
  </style>

but that has no effect. 但那没有效果。 I know this his probably been asked but i can't find the right solution. 我知道这可能是他被问到但是我找不到合适的解决方案。 any ideas? 有任何想法吗? ps i'm actually using sherlock action bar if that matters ps我实际上正在使用sherlock动作栏,如果重要的话

in the end this is what i did, maybe this will help someone: 最后这就是我所做的,也许这会对某人有所帮助:

<style name="Theme.Styled" parent="Theme.Sherlock.Light.DarkActionBar">
        <item name="actionBarStyle">@style/Widget.Styled.ActionBar</item>
        <item name="android:actionBarStyle">@style/Widget.Styled.ActionBar</item>
        <item name="actionDropDownStyle">@style/xxx.ActionBar.DropDown.Style</item>
        <item name="android:actionDropDownStyle">@style/xxx.ActionBar.DropDown.Style</item>
    </style>
   <style name="Widget.Styled.ActionBar" parent="Widget.Sherlock.Light.ActionBar.Solid.Inverse">
        <item name="background">#0B2F39</item>
        <item name="android:background">#0B2F39</item>
        <item name="backgroundSplit">#0B2F39</item>
        <item name="android:backgroundSplit">#0B2F39</item>
    </style>

    <style name="xxx.ActionBar.DropDown.Style" parent="Widget.Sherlock.Light.Spinner.DropDown.ActionBar">
        <item name="android:background">@drawable/abs__spinner_ab_holo_dark</item>
    </style>

if you have any remark or corretions i would love to hear them 如果你有任何评论或更正,我很乐意听到他们

If you already use an custom theme(you extended the base theme and customized it) and you want to customize the spinner only for one activity you need to do this: 如果您已经使用了自定义主题(扩展了基本主题并对其进行了自定义),并且您只想为一个活动自定义微调器,则需要执行以下操作:

<style name="Theme.MyTheme" parent="Theme.Sherlock">
... your other items
</style>

<style name="Theme.MyTheme.Spinner" parent="Theme.MyTheme">
    <item name="android:spinnerItemStyle">@style/SpinnerItem</item>
    <item name="android:spinnerDropDownItemStyle">@style/SpinnerItem.DropDownItem</item>
</style>

<style name="Spinner" parent="@android:style/Widget.Spinner">
    <item name="android:spinnerItemStyle">@style/SpinnerItem</item>
    <item name="android:spinnerDropDownItemStyle">@style/SpinnerItem.DropDownItem</item>
</style>    
<style name="SpinnerItem" parent="@android:style/Widget.TextView.SpinnerItem">
    <item name="android:textColor">@android:color/white</item>
</style>
<style name="SpinnerItem.DropDownItem" parent="@android:style/Widget.Holo.Light.DropDownItem.Spinner">
    <item name="android:textColor">@android:color/white</item>
</style>

And to use this style in an activity use this: 要在活动中使用此样式,请使用以下命令:

<activity
    android:name=".YourActivity"
    android:theme="@style/Theme.MyTheme.Spinner"  >
</activity>

If you want to customize the spinner for all the activities(your application) move the items from Theme.MyTheme.Spinner into Theme.MyTheme : 如果要为所有活动(您的应用程序)自定义微调器,请将项目从Theme.MyTheme.Spinner移动到Theme.MyTheme

<style name="Theme.MyTheme" parent="Theme.Sherlock">
   ... your other items
   <item name="android:spinnerItemStyle">@style/SpinnerItem</item>
   <item name="android:spinnerDropDownItemStyle">@style/SpinnerItem.DropDownItem</item>
</style>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM