我已经创建了一个示例android应用程序,它只显示一些文本,我可以看到活动顶部的菜单栏包含应用程序的名称,但没有包含应用程序的图标。菜单也很薄,只包含一个小字体的应用程序名称。通过不同的教程,我发现我们在创建应用程序时必须选择一种特定的菜单样式,才能有一个同时包含应用程序名称和图标的菜单,但我的应用程序只包含应用程序名称,并且菜单非常薄。有没有可能现在增加菜单高度,并动态添加应用程序图标,或通过在菜单xml文件中进行一些更改?
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/app_name" android:icon="@drawable/ic_launcher"
android:title="My App" />
</menu>发布于 2014-10-27 20:45:56
如果你想自定义ActionBar,这里有一个完整的教程:
How can I implement custom Action Bar with custom buttons in Android?
它非常适合定制几乎所有的东西,所以我向你推荐它。
即使很难,我也要求你改变你的问题,以便更清楚地说明它的目标,现在你知道你在尝试什么意思了;)
发布于 2015-03-24 23:35:23
<menu xmlns:tools="schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:context="com.example.sample.getMsgActivity"
xmlns:yourapp="http://schemas.android.com/apk/res-auto">
<!-- Search, should appear as action button -->
<item android:id="@+id/action_write"
android:icon="@drawable/ic_action_refresh"
android:title="@string/action_write"
yourapp:showAsAction="ifRoom" />
<!-- Settings, should always be in the overflow -->
<item android:id="@+id/action_read"
android:title="@string/action_read"
yourapp:showAsAction="never" />
请记住:先清理,然后构建。那么它应该可以工作了。
https://stackoverflow.com/questions/26584058
复制相似问题