如何同时显示图标和内部动作条行动头衔?图标、头衔、行动、动作

2023-09-12 21:45:30 作者:浅瞳

我需要显示这两个图标标题动作条。

I need to display both icon and title of action inside ActionBar.

我已经试过 withText 选项,但没有效果。

I've tried "withText" option, but it has no effect.

推荐答案

总是| withText 将工作,如果有足够的空间,否则只会地方图标。你可以旋转你的手机上进行测试。

'always|withText' will work if there is sufficient room, otherwise it will only place icon. You can test it on your phone with rotation.

<item android:id="@id/menu_item"
android:title="text"
android:icon="@drawable/drawable_resource_name"
android:showAsAction="always|withText" />