简体   繁体   English

Android自定义标签栏

[英]Android Custom Tab Bar

I am looking to create a tabbed application similar to Iphone's tab-bar. 我正在寻找一个类似于Iphone的选项卡栏的选项卡式应用程序。 There will be a bottom tab bar in my app which will go to certain screens. 我的应用程序中将有一个底部的标签栏,它将转到某些屏幕。

(example of my page layout): (我的页面布局示例):
[ tab1 ] Book List -> Book Details [ tab1 ]图书清单->图书详细信息
[ tab2 ] Settings1 -> Settings2 [ tab2 ]设置1- >设置2
[ tab3 ] About [ tab3 ]关于

I need each tab to have its own separate navigation stack. 我需要每个选项卡都有其自己的单独的导航堆栈。 So if I go from Book List to Settings1, to Settings2 and press back, I expect to be on Settings1. 因此,如果我从“书目清单”转到“设置1”,再到“设置2”并按回,则我希望它位于“设置1”上。 From there if I press back, I expect to still stay on Settings1 because all the tabs are separate from each other. 如果我按回去,我希望仍然停留在Settings1上,因为所有选项卡都是彼此分开的。

1) I tried using Android's native Tab Host but the tabs are placed at the top... so I placed the tabs at the bottom in my XML layout. 1)我尝试使用Android的本机Tab Host,但选项卡位于顶部...因此我将这些选项卡置于XML布局的底部。

Issue : However my phone's scroll wheel doesn't work properly: When I'm on the tab and I want to get to the above content, I scroll UP (GOOD). 问题 :但是手机的滚轮无法正常工作:当我在选项卡上并且想要获取上述内容时,我向上滚动(GOOD)。 When I'm on the content and want to get to the below tab I have to scroll UP (BAD, you should scroll DOWN to get it). 当我在内容上并想要转到下面的选项卡时,我必须向上滚动(不良,您应该向下滚动以获取它)。

Is it possible to scroll down to reach the tab and scroll up to go back to the content? 是否可以向下滚动以到达选项卡,然后向上滚动以返回至内容?

2) Does anybody know any other lesser-GPL API that can achieve this? 2)是否有人知道可以实现此目标的其他小GPL API? Or must I start from scratch? 还是我必须从头开始?

Thanks. 谢谢。

You can use layout_gravity="bottom" in TabWidget to show tab bar in bottom like this: 您可以在TabWidget使用layout_gravity="bottom"layout_gravity="bottom"显示标签栏,如下所示:

<TabWidget 
    android:id="@android:id/tabs"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:layout_width="fill_parent">
</TabWidget>

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

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