Android,没有操作栏的标签

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23843479/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:31:18  来源:igfitidea点击:

Android, Tabs without Actionbar

androidandroid-tabs

提问by Taxi Noi Bai Ha Noi

This question has been asked (for example, here Using ViewPager with Tabs without actionBar), however the answer there doesn't work. There's some links to Swipeybut unfortunately the link is broken too.

这个问题已经被问到(例如,这里Using ViewPager with Tabs without actionBar),但是那里的答案不起作用。有一些指向Swipey的链接,但不幸的是,该链接也已损坏。

The example from Android site EffectiveNavigationuses Actionbar to host the tab fragment, so obviously if I set a .NoActionBar theme, then there's no host. Any different way? Thanks.

Android 网站EffectiveNavigation的示例使用 Actionbar 来托管选项卡片段,因此很明显,如果我设置了 .NoActionBar 主题,则没有主机。有什么不同的方式吗?谢谢。

Updatescreenshot of what I want to create, at the top, there's no actionbar. enter image description here

更新我想要创建的屏幕截图,在顶部,没有操作栏。 在此处输入图片说明

Update 2this is from the google example, there's an actionbar on top (titled "Effective navigation), which I want to get rid of

更新 2这是来自 google 示例,顶部有一个操作栏(标题为“有效导航”),我想摆脱它

enter image description here

在此处输入图片说明

回答by Pragnesh Ghoda シ

Solution of your problem is already given in http://developer.android.com/

您的问题的解决方案已在http://developer.android.com/ 中给出

To disableAction-bar Icon and Title, you must do two things:

要禁用操作栏图标和标题,您必须做两件事:

 setDisplayShowHomeEnabled(false);  // hides action bar icon
 setDisplayShowTitleEnabled(false); // hides action bar title

Follow The Steps given in Using split action bar

按照使用拆分操作栏中给出的步骤

Write Following Code in OnCreate()

编写以下代码 OnCreate()

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.navigation_drawer);

        getActionBar().setDisplayShowHomeEnabled(false);  // hides action bar icon
        getActionBar().setDisplayShowTitleEnabled(false); // hides action bar title
        //rest of your code...
}

enter image description here

在此处输入图片说明

After Android updated Actionbar to Toolbar there are many changes in Actionbar Tabs.

Android 将 Actionbar 更新为 Toolbar 后,Actionbar Tabs 中有很多变化。

Please follow below links to create swipable tabs in Andoid.

请按照以下链接在 Andoid 中创建可滑动的标签。

Design Structure :

设计结构:

Tabs Design Guidelines

标签设计指南

enter image description here

在此处输入图片说明

Some of the very useful links are below. Please refer to them.

一些非常有用的链接如下。请参考它们。

Download sample zip from below link

从以下链接下载示例 zip

http://developer.android.com/samples/SlidingTabsBasic/index.html

http://developer.android.com/samples/SlidingTabsBasic/index.html

Or Refer these links

或参考这些链接

http://www.android4devs.com/2015/01/how-to-make-material-design-sliding-tabs.html

http://www.android4devs.com/2015/01/how-to-make-material-design-sliding-tabs.html

http://www.exoguru.com/android/material-design/navigation/android-sliding-tabs-with-material-design.html

http://www.exoguru.com/android/material-design/navigation/android-sliding-tabs-with-material-design.html

http://www.truiton.com/2015/06/android-tabs-example-fragments-viewpager/

http://www.truiton.com/2015/06/android-tabs-example-fragments-viewpager/

https://guides.codepath.com/android/Google-Play-Style-Tabs-using-TabLayout

https://guides.codepath.com/android/Google-Play-Style-Tabs-using-TabLayout

This may help you...

这可能会帮助你...

回答by CommonsWare

You can:

你可以:

  • Use a ViewPagerwith a PagerTabStrip

  • Use a ViewPagerwith the TabPageIndicatorclass from the ViewPagerIndicator library

  • Use a ViewPagerwith other third-party tab indicators (e.g., in the "View Pagers" category at the Android Arsenal)

  • Use a ViewPagerand design your own tabbed indicator

  • Use a FragmentTabHostand skip the swiping part

  • 使用ViewPager一个PagerTabStrip

  • 将 aViewPagerTabPageIndicatorViewPagerIndicator 库中的类一起使用

  • 使用ViewPager(例如,与其他第三方选项卡指标在Android的阿森纳“查看传呼机”类别

  • 使用ViewPager并设计您自己的选项卡式指示器

  • 使用 aFragmentTabHost并跳过滑动部分

回答by Ali Akram

Along with

随着

getActionBar().setDisplayShowHomeEnabled(false);
getActionBar().setDisplayShowTitleEnabled(false);

Use this as well

也用这个

getActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);