查找出来,如果​​动作条堆叠 [英] Find out if ActionBar is stacked

查看:129
本文介绍了查找出来,如果​​动作条堆叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您添加标签到你的动作条,他们将在动作条堆积额外的电话在纵向模式。有没有一种简单的方法,以找出是否会发生?

If you add tabs to your ActionBar, they will be in an extra stacked ActionBar on phones in portrait mode. Is there an easy way to find out whether this happened?

我已经把它贴在YouTube应用程序的两个截图。第一个显示正常动作条在它的选项卡,第二个显示在标签堆叠动作条

I've attached two screenshots of the YouTube app. The first one shows the normal ActionBar with the tabs in it, the second one shows the tabs in a stacked ActionBar.

推荐答案

有可能找出是否存在由IS的身高在操作栏中一行或两行。有法 的getHeight() ,但它不会在正常工作的onCreate ONSTART ,它将返回只有当活动已经开始了真正的价值。

It is possible to find out if there is one or two lines in action bar by is's height. There is method getHeight(), but it will not work in onCreate or onStart, it will return real value only if activity already started.

在动作条横向高度 40dip (80/60/40/30 PX在不同的屏幕),在纵向的标签是96dp(192 / 144/96/72像素)。

In landscape orientation height of action bar is 40dip (80/60/40/30 px on different screens), in portrait orientation with tabs it is 96dp (192/144/96/72 px).

这不是靠这个最好的主意,但我找不到任何其他的方式,以找出是否卡在里面行动吧。

It is not the best idea to rely on this, but I can't find any other way to find out if tabs is inside action bar.

这篇关于查找出来,如果​​动作条堆叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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