Android ActionBar - 如何检查当前可见的操作栏按钮数量?

标签 android android-actionbar

有没有办法检查有多少按钮可见,有多少按钮隐藏在overflow中? 因为,众所周知,根据设备的不同,ActionBar 中可以容纳不同数量的按钮。

为什么我需要它?我正在尝试放置一个指向特定操作按钮的箭头。为了正确放置它,我需要知道这个按钮是隐藏在溢出中,还是从右边缘开始第 3 个?

最佳答案

Is there any way to check how many buttons are visible, and how many are hidden in overflow?

我不这么认为。据我所知,isVisible() 将为溢出区域中的项目返回 true,因为它与 MenuItem 的单独“可见性”方面相关联.

I'm trying to place an arrow which will point to a particular action button. And to place it correctly, I need to know if this button is hidden in overflow, or is 3rd from the right edge?

不,您需要知道按钮的像素坐标,它会根据许多因素而变化,除了它是否在溢出区域之外,例如实际屏幕密度。

关于Android ActionBar - 如何检查当前可见的操作栏按钮数量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13205411/

相关文章:

android - 自定义ActionBar形状android

android - 为什么没有用于获取当前 Activity 的Android API?

android - 在不同的过程中打开相机

android - 如何在 Android 上将 UTC 日期转换为语言环境 GMT 时间

Android 操作栏 : Set text color of action view?

android - 在达到限制时使 ActionBar 上的选项卡滚动,而不是创建下拉列表

android - SearchView 中的 ActionBar 麦克风按钮(语音搜索)

android - 在 Android 中选择多个图像

java - 将 EditText 的值设置为自己的值,已修改 - 导致卡住

java - 键盘打开时自定义操作栏隐藏