如何对齐操作栏项目向左? [英] How to align items in action bar to the left?

查看:97
本文介绍了如何对齐操作栏项目向左?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个搜索查看的动作条,但我想,将其调整到左比如在地图应用程序,而不是正确的。我将如何做到这一点?

I have an actionbar with a searchview but I'd like to align it to the left such as in the maps app as opposed to the right. How would I do this?

推荐答案

你可以做到这一点 试试这个它会确定帮助:

You can do this Try this it would definetly help:

ActionBar action=getActionBar();
action.setDisplayShowCustomEnabled(true);
action.setDisplayShowHomeEnabled(false);
action.setDisplayShowTitleEnabled(false);
RelativeLayout relative=new RelativeLayout(getApplicationContext());
relative.addView(new SearchView(getApplicationContext()));
action.setCustomView(relative);

不要忘了布局PARAMS添加到您的搜索查看,以便它可以在对准右侧相对。 不要让我知道是否有问题了。 谢谢

Do not forget to add layout params to your searchview so that it may align on right to relative. Do let me know if any issue got. Thank You

这将是随后在操作栏右侧显示。 此外

it would be then shown on right of action bar. Also

这篇关于如何对齐操作栏项目向左?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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