Find out if ActionBar is stacked

前端 未结 3 1952
[愿得一人]
[愿得一人] 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.

    0 讨论(0)
  • 2020-12-30 02:07

    This behavior is called Split Action Bar. It happens when the AndroidManifest is set with uiOptions="splitActionBarWhenNarrow" in the <activity> or <application> element.

    Android adjusts the action bar's appearance in a variety of ways, based on the current screen size. Using split action bar is just one option that you can enable to allow the action bar to further optimize the user experience for different screen sizes. In doing so, you may also allow the action bar to collapse navigation tabs into the main action bar. That is, if you use navigation tabs in your action bar, once the action items are separated on a narrow screen, the navigation tabs may be able to fit into the main action bar rather than be separated into the "stacked action bar".

    Mock-ups of split action bar with navigation tabs on the left; with the app icon and title disabled on the right.

    You can get more details here.

    0 讨论(0)
  • 2020-12-30 02:16

    well i have created an actionBar similar to Instagram with a bottom ActionBar without the need of using Tabs. have a look at this image . i'v answered this related question on another question 10 minutes ago. CustomView ActionBar And Fake Bottom ActionBar in order for you to do this you have to create three separate layouts. one for the bottom to use it as Include and one for the ActionBar To use it As ActionBar View.

    if you check my latest answers you'll find how i did this. hope that benefits you in anyway. cheers

    0 讨论(0)
提交回复
热议问题