android studio toolbar 搜索,android studio开发,toolbar上的searchview图标如何更改?

bVqOOn

默认的icon是黑色的,如何更改为白色?

在toolbar的menu里改icon文件没有效果

bVqOOt

更改图像编码onPrepareOptionsMenu在这段我建议创建一个方法,通过菜单项从onprepareoptionsmenu在那方法做的任务。

Update

搬运工

How to change SearchView default icon?

Changing the background drawable of the searchview widget

Unfortunately, there is no easy way to change the SearchView icon to a custom drawable, since the theme attribute searchViewSearchIcon is not public. See this answer for details.

However, I think that your problem is caused by inheriting from the wrong theme. Please use > android:Theme.Holo.Light.DarkActionBar as the base for your theme. Then the default icons on > the action bar should have a light color.

<style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">

...

</style>

我的测试结果:

values-v14/styles.xml

中设置style为

android:Theme.Holo.Light

,对应图片的上部分;

设置style为

android:Theme.Holo.Light.DarkActionBar

,对应图片的下部分;

bVqOSr

Old Answer: 这段代码确实改不了SearchView icon,只能改普通的 menu item

@Override

public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu items for use in the action bar

MenuInflater inflater = getMenuInflater();

inflater.inflate(R.menu.menu_full_player, menu);

MenuItem item = menu.findItem(R.id.catcher_action_playPause);

Drawable icon = getResources().getDrawable(R.drawable.ic_pause_circle_outline_white_36dp);

item.setIcon(icon);

return super.onCreateOptionsMenu(menu);

}

950-390_%E7%94%BB%E6%9D%BF-1.jpg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值