操作栏图标隐藏搜索查看后扩大 [英] Action Bar Icon hidden after SearchView expands

查看:204
本文介绍了操作栏图标隐藏搜索查看后扩大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想即使在搜索查看扩展搜索查看(云)旁边的图标总是显示的。这可以正常使用,但片剂小型设备的情况下,如Nexus 5不起作用。

I want the icon beside the SearchView (the "cloud") stays visible even when the SearchView expands. This works properly for tablets but doesn't work in case of smaller devices like Nexus 5.

我在 showAsAction =总是此菜单项设置。此外,搜索查看有这个属性。 showAsAction =ifRoom

I have set the showAsAction="always" for this menu item. Also, the SearchView has this attribute: showAsAction="ifRoom".

推荐答案

试试这个,使用我的作品应用程序兼容性V21

try with this, works for me using appCompat v21

final MenuItem switchButton = menu.findItem(R.id.action_import);
final MenuItem searchItem = menu.findItem(R.id.action_search);

MenuItemCompat.setShowAsAction(searchItem, MenuItemCompat.SHOW_AS_ACTION_ALWAYS);
MenuItemCompat.setShowAsAction(switchButton, MenuItemCompat.SHOW_AS_ACTION_ALWAYS); 

这篇关于操作栏图标隐藏搜索查看后扩大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆