问题
Is there a way to position the title text for a menu item to the left of the icon rather than to the right in an ActionBar? So in:
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/forward"
android:title="Begin"
android:icon="@drawable/ForwardArrow"
android:showAsAction="always"></item>
</menu>
It would appear "Begin ->" instead of "-> Begin"
回答1:
While you can define things like android:actionButtonStyle in a theme and apply that to your activity, I am not aware that you can use that to turn around and affect the positioning of the image versus the text.
However, you can use android:actionLayout in your <item> element to replace the stock action button with something else of your own design. If you putter around the Android source and find where these action buttons come from, I suspect that you will find that they are styled Button objects using the compound drawable stuff to put an image alongside the text caption. Cloning that and switching the side for the image, then using that for your actionLayout, should work, at least in theory.
来源:https://stackoverflow.com/questions/11368260/menu-resource-item-position-title-to-left-of-icon