Menu Resource Item Position Title to Left of Icon

爱⌒轻易说出口 提交于 2020-01-05 14:24:53

问题


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

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