有没有标准的方法可以在 Android 3.0 中的操作栏项目之间添加分隔线? [英] Is there a standard way to add dividers between action bar items in Android 3.0?

查看:20
本文介绍了有没有标准的方法可以在 Android 3.0 中的操作栏项目之间添加分隔线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试自定义应用程序中操作栏的外观时遇到了一个小问题.我希望能够使用像素宽的分隔线来对您在许多本机应用程序(例如 Gmail、日历)中看到的操作栏项目进行分组.我找到了一种方法,通过添加菜单项并将android:actionLayout"属性设置为分隔线的自定义布局:

I have a slight problem trying to customise the look of the action bar in my app. I want to be able to have the pixel wide dividers to group action bar items that you see in many of the native apps (e.g. Gmail, Calendar). I found a way to do this by adding a menu item and setting the 'android:actionLayout' attribute to a custom layout for the divider:

<View
  android:background="@color/LightGray"
  android:layout_marginTop="5dip"
  android:layout_marginBottom="5dip"
  android:layout_width="1dip"
  android:layout_height="fill_parent" />

这很好用,但问题是它算作一个菜单项,而操作栏似乎将菜单项的数量限制为 4 - 任何其他菜单项都会被推入溢出菜单.

This works nicely, but the issue is it counts as a menu item and the action bar seems to limit the number of menu items to 4 - any others get pushed into the overflow menu.

所以我想我要问的是是否有一种标准的方法来添加项分隔符而不必使用带有自定义视图的菜单项,并且以不计入操作栏项限制的方式?

So I guess what I'm asking is whether there is a standard way to add item dividers without having to use a menu item with a custom view, and in a way that doesn't count towards the limit for action bar items?

提前致谢!

推荐答案

我不会尝试将分隔符强加到系统不会自动添加的位置,因为这会使您的应用与平台不一致.默认行为是:

I wouldn't try and force dividers into places that the system does not add them automatically as it will make your app inconsistent with the platform. The default behavior is:

  • 溢出和其他之间的分隔符.
  • 文本和另一个项目之间的分隔符,它可以消除文本所属的项目的歧义.

这篇关于有没有标准的方法可以在 Android 3.0 中的操作栏项目之间添加分隔线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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