Android 3.0: cannot style Action Bar 's action item buttons

女生的网名这么多〃 提交于 2019-12-04 19:33:01

Most style elements will work but padding is supplied by the system layouts used to generate the action buttons and likely will not do what you expect. Most action bar metrics such as padding and margins should generally be left alone for UX consistency. Even the item padding attribute you noted is meant to be informational for apps that may want to use it to style their own custom action views.

If you wanna change text parametres like text size, color or style, you must use actionMenuTextAppearance. Here is my code for ActionBarSherlock:

<item name="actionMenuTextAppearance">@style/MyProject.ActionMenuTextAppearance</item>
<item name="android:actionMenuTextAppearance">@style/MyProject.ActionMenuTextAppearance</item>

...

<style name="MyProject.ActionMenuTextAppearance" parent="TextAppearance.Sherlock.Widget.ActionBar.Menu">
    <item name="android:textSize">15sp</item>
    <item name="android:textStyle">normal</item>
    <item name="android:textAllCaps">false</item>
</style>

EDIT: This is my template for styling action bar with ActionBarSherlock: https://github.com/petrnohejl/Android-Templates-And-Utilities/tree/master/Res-Theme-Holo-Deprecated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!