简体   繁体   English

将 android 标签放在操作栏的中心

[英]Put android tabs in center of action bar

I tried Android action bar with tabs.我尝试了带有标签的 Android 操作栏。 As you see in this picture:正如你在这张图片中看到的:

这个
(source: persiangig.com ) (来源: persiangig.com

My action bar looks good in phones but in tablets it is not right, the tabs stick left.我的操作栏在手机中看起来不错,但在平板电脑中它不正确,标签粘在左边。 This picture shows what I mean, how can I put the tabs to center in tablets too?这张图片显示了我的意思,我如何将标签也放在平板电脑的中心?

这个
(source: persiangig.com ) (来源: persiangig.com

The tabs are aligned left because, in Android, the action bar is used for both navigation and Activity- or Fragment-specific actions.选项卡左对齐是因为在 Android 中,操作栏用于导航和特定于 Activity 或 Fragment 的操作。 You don't have any in this screenshot, but menu actions that are added to the action bar will be aligned to the right.此屏幕截图中没有任何操作,但添加到操作栏的菜单操作将向右对齐。

If you must have your tabs centered for some reason, you'll have to write your own action bar.如果出于某种原因必须将选项卡居中,则必须编写自己的操作栏。 I would recommend against this, since it's a lot of work to intentionally go against user expectations.我建议不要这样做,因为有意违背用户期望需要做很多工作。 Instead, use Android's built-in action bar layout and design your app to accommodate it.相反,使用 Android 的内置操作栏布局并设计您的应用程序以适应它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM