【问题标题】:Android - ActionBarSherlock - Set textcolor of text in submenuAndroid - ActionBarSherlock - 在子菜单中设置文本的文本颜色
【发布时间】:2012-05-30 22:39:34
【问题描述】:

如何在动作栏 Sherlock 的子菜单中设置文本颜色?我可以设置背景但不能设置文本颜色.. =(

temas.xml

<style name="Tema.Laranja" parent="Theme.Sherlock.Light.ForceOverflow">

    <item name="actionBarItemBackground">@drawable/background_selecionado</item>
    <item name="android:actionBarItemBackground">@drawable/background_selecionado</item>

    <item name="android:dropDownListViewStyle">@style/Tema.Laranja.ListSelector</item>
    <item name="dropDownListViewStyle">@style/Tema.Laranja.ListSelector</item>

    <item name="popupMenuStyle">@style/Tema.Laranja.Popup</item>
    <item name="android:popupMenuStyle">@style/Tema.Laranja.Popup</item>
</style>

    <style name="Tema.Laranja.Popup" parent="Widget.Sherlock.Light.PopupMenu">
    <item name="android:popupBackground">@drawable/shape_laranja_arredondado</item>
</style>

<style name="Tema.Laranja.ListSelector" parent="Widget.Sherlock.ListView.DropDown">
    <item name="android:listSelector">@color/listview_actionbar</item>
    <item name="android:textColor">@color/branca</item>
    <item name="android:drawSelectorOnTop">true</item>
</style>

我的 listview_actionbar.xml

<item android:state_focused="false"
    android:drawable="@drawable/shape_amarelo_arredondado"/>

<!-- Even though these two point to the same resource, have two states so the drawable will invalidate itself when coming out of pressed state. -->
<item android:state_focused="true" android:state_enabled="false"
    android:state_pressed="true"
    android:drawable="@drawable/shape_amarelo_arredondado" />
<item android:state_focused="true" android:state_enabled="false"
    android:drawable="@drawable/shape_amarelo_arredondado" />

<item android:state_focused="true" android:state_pressed="true"
    android:drawable="@drawable/shape_amarelo_arredondado" />
<item android:state_focused="false" android:state_pressed="true"
    android:drawable="@drawable/shape_amarelo_arredondado" />

<item android:state_focused="true"
    android:drawable="@drawable/shape_amarelo_arredondado" />

【问题讨论】:

  • 我已经尝试了这两个答案,但都不适合我。

标签: android android-actionbar actionbarsherlock submenu textcolor


【解决方案1】:
<style name="MyPopupMenu" parent="Widget.Sherlock.ListPopupWindow">
        <item name="android:popupBackground">@drawable/dropdown_selector</item>
        <item name="android:textAppearance">@style/TextAppearance.Sherlock.Widget.PopupMenu</item>
</style>

<style name="TextAppearance.Sherlock.Widget.PopupMenu" parent="Widget">
        <item name="android:textColor">@color/branco</item>
</style>

【讨论】:

    【解决方案2】:

    尝试使用

    <item name="android:textAppearanceLargePopupMenu">
        <!-- @style/some style that has android:textColor as attribute -->
    </item> <!-- in Tema.Laranja style -->
    

    【讨论】:

      【解决方案3】:

      使用 actionBarWidgetTheme 和 android:textColor。

      例子:

      <style name="Theme.Guide" parent="Theme.Sherlock.Light.DarkActionBar">
          <item name="android:actionBarWidgetTheme">@style/ActionBar.Widget.Guide</item>
          <item name="actionBarWidgetTheme">@style/ActionBar.Widget.Guide</item>
      </style>
      
      <style name="ActionBar.Widget.Guide" parent="Widget.Sherlock.ActionBar.Solid">
          <item name="android:textColor">@android:color/white</item>
          <item name="android:textSize">@dimen/action_bar_dropdown_menu_text_size</item>
      </style>
      

      【讨论】:

        猜你喜欢
        • 2012-05-31
        • 1970-01-01
        • 2015-08-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-11
        • 1970-01-01
        相关资源
        最近更新 更多