ces*_*rds 4 android actionbarsherlock android-actionbar
我一直在尝试创建自己的动作项目,但对我来说这是不可能的.
我正在尝试做的是创建自定义操作项布局(例如颜色背景),类似"拇指"操作栏.我只想为我的一项活动更改操作项.

我一直在玩动作菜单项的android:icon和android:actionLayout属性..但我一无所获.
实际上,我在StackOverflow中看到了另一个线程,但它对我没有帮助......
在ActionBarSherlock中使用自定义布局构建ActionMode
样式ActionbarSherlock:action-items的textColor
有任何想法吗?提前致谢!
Mic*_*ert 12
要覆盖ActionBarSherlock主题,您应该像这样继续:
values/abs__themes.xml从ActionBarSherlock图书馆项目开放.你看到例如:
<style name="Theme.Sherlock" parent="Sherlock.__Theme">
<!-- Action bar styles (from Theme.Holo) -->
<item name="actionDropDownStyle">@style/Widget.Sherlock.Spinner.DropDown.ActionBar</item>
<item name="actionButtonStyle">@style/Widget.Sherlock.ActionButton</item>
<item name="actionOverflowButtonStyle">@style/Widget.Sherlock.ActionButton.Overflow</item>
<item name="actionModeBackground">@drawable/abs__cab_background_top_holo_dark</item>
<item name="actionModeSplitBackground">@drawable/abs__cab_background_bottom_holo_dark</item>
<item name="actionModeCloseDrawable">@drawable/abs__ic_cab_done_holo_dark</item>
<item name="actionBarTabStyle">@style/Widget.Sherlock.ActionBar.TabView</item>
...
// Here is what you wanted
<item name="actionBarItemBackground">@drawable/abs__item_background_holo_dark</item>
...
Run Code Online (Sandbox Code Playgroud)
当您找到要自定义的项目(actionBarItemBackground在您的情况下)时,您themes.xml在项目中创建自己的项目,并添加其中:
<style name="Custom.Theme.Sherlock" parent="@style/Theme.Sherlock">
<item name="actionBarItemBackground">@drawable/my__item_background_holo_dark</item>
</style>
Run Code Online (Sandbox Code Playgroud)
这将覆盖默认Theme.Sherlock设置,设置自定义actionBarItemBackground.
现在,Theme.Sherlock您应该使用而不是在您的活动中使用setTheme(R.style.Custom_Theme_Sherlock).您可能还想覆盖其他两个主题(Theme.Sherlock.Light和Theme.Sherlock.Light.DarkActionBar)
还有一个提示,这里是用于ActionBarSherlock默认操作项背景的可绘制选择器(在holo_light中),它使用9-patch png drawables:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- 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/abs__list_selector_disabled_holo_light" />
<item android:state_focused="true" android:state_enabled="false" android:drawable="@drawable/abs__list_selector_disabled_holo_light" />
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/abs__list_selector_background_transition_holo_light" />
<item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/abs__list_selector_background_transition_holo_light" />
<item android:state_focused="true" android:drawable="@drawable/abs__list_focused_holo" />
<item android:drawable="@android:color/transparent" />
Run Code Online (Sandbox Code Playgroud)
对于其他基本自定义,您可以使用此工具,它为您生成样式.
| 归档时间: |
|
| 查看次数: |
5489 次 |
| 最近记录: |