【问题标题】:Android ActionBar overflow checkbox styleAndroid ActionBar 溢出复选框样式
【发布时间】:2014-10-02 04:32:34
【问题描述】:

在我的应用程序中,我有一个用于复选框的自定义可绘制对象,默认情况下它在常规界面区域中始终有效,但是当有可检查项目时,它不会显示在溢出菜单中,而是显示默认值全息复选框!

这是自定义复选框的示例

这就是我如何设置溢出菜单的样式(非常困难),我正在寻找一种可以覆盖复选框的样式

<style name="OverflowMenu" parent="@style/Widget.Sherlock.ListPopupWindow">
    <item name="android:popupBackground">@drawable/pop_dark</item>
</style>

<style name="DropDownListView" parent="@android:style/Widget.Holo.ListView.DropDown">
    <item name="android:divider">@android:color/transparent</item>
</style>

【问题讨论】:

  • 你有想过这个吗?
  • 不幸的是,我认为唯一的解决方案是手动实现一个弹出菜单,并有一个自定义列表项。但这显然在整个项目中都非常耗时。
  • 感谢您的快速回复。如果我弄清楚了,我会在这里发帖。
  • 作为题外话 - 你有什么理由坚持使用 ActionBarSherlock 而不使用 ActionBarCompat?

标签: android checkbox android-actionbar actionbarsherlock


【解决方案1】:

如果您在主题中覆盖 android:listChoiceIndicatorMultiple,它将适用于所有复选框,包括普通 UI 中的复选框以及弹出菜单中的复选框,即

<style name="AppTheme" parent="android:Theme...">
    <item name="android:listChoiceIndicatorMultiple">@style/YourCheckBoxStyle</item>
</style>

如果您只想为 ActionBar 中的复选框设置主题,那么您可以从 API 14 开始使用android:actionBarWidgetTheme

<style name="AppTheme" parent="android:Theme...">
    <item name="android:actionBarWidgetTheme">@style/MyActionBarWidgetScheme</item>
</style>
...
<style name="ActionBarWidgetTheme" parent="android:Widget">
    <item name="android:listChoiceIndicatorMultiple">@drawable/YourCheckBoxStyle</item>
</style>

(感谢 Daniel Lew pointing that one out。)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 1970-01-01
    相关资源
    最近更新 更多