作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:appcompat="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MainActivity">
<item
android:id="@+id/action_search"
android:icon="@drawable/search"
appcompat:actionViewClass="android.support.v7.widget.SearchView"
appcompat:showAsAction="ifRoom"
android:title="Search"/>
</menu>
我想更改 search image右上角,目前是黑色,我想改成橙色
最佳答案
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_notifications, menu);
this.menu = menu;
super.onCreateOptionsMenu(menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_clear_all) {
showToast("Clear All");
return true;
}
return super.onOptionsItemSelected(item);
}
在res>菜单下创建xml文件。
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".YourActivityName" >
<item
android:id="@+id/action_clear_all"
android:title="@string/noti_clear_all"
android:icon="@drawable/ic_clear_all"
android:orderInCategory="100"
app:showAsAction="ifRoom" />
</menu>
关于android - 如何在android中自定义工具栏上的搜索图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36763462/
我是一名优秀的程序员,十分优秀!