Find out if ActionBar is stacked

前端 未结 3 2074
[愿得一人]
[愿得一人] 2020-12-30 01:42

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

3条回答
  •  暖寄归人
    2020-12-30 01:55

    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.

    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.

提交回复
热议问题