2013-09-22 60 views
5

我一直在寻找一种方法让我的android应用程序在屏幕底部有标签。Android - 屏幕底部的标签

论样式和主题部分Android开发者网站,他们似乎有什么我试图做精确的例子,但是他们并没有觉得有必要提供这样一个体面的例子:

enter image description here

我在网上找到的所有提示/解决方案都失败了。我似乎总是得到下面的对接丑陋的布局,其中的选项卡在屏幕的顶部非常错位的应用程序的名称:-(

enter image description here

旁边有没有人有一个线索如何做到这一点?

非常感谢你提前任何提示

+0

这是没有标签,但分裂的ActionBar。您可以在Android开发人员指南(http://developer.android.com/guide/topics/ui/actionbar.html)中阅读关于它的更多信息。 – Ridcully

+0

@韦斯利,这是一个“分割动作栏”视图功能。你可以找到一些很好的例子。你需要在'Android Manifest'中定义属性。 – 2013-09-22 14:15:52

回答

11

我觉得这些例子对你有用:Android Bottom tab bar exampleTHIS

+5

虽然这可能在理论上回答这个问题,但[这将是更可取的](http://meta.stackoverflow.com/q/8259)在这里包括答案的基本部分,并提供供参考的链接。 – Keelan

1

我觉得你没有足够的搜索你的问题,因为你使用了错误的关键字搜索。

什么你是显示在Gmail应用程序的底部在第一图象有4个菜单和第五溢出菜单,并以最快的动作条上

可以放置在使用清单一个简单的属性底部的菜单;在主要活动一个单一的线,显示操作栏

android:uiOptions="splitActionBarWhenNarrow"

像这样:

<activity 
    android:name="com.example.HomeActivity" 
    android:screenOrientation="portrait" 
     android:uiOptions="splitActionBarWhenNarrow" 
    android:theme="@style/Theme.Sherlock.Light" > 
    <intent-filter> 
     <action android:name="android.intent.action.MAIN" /> 

     <category android:name="android.intent.category.LAUNCHER" /> 
    </intent-filter> 
</activity> 
0

它非常简单....

对于简单的标签栏,我们使用

<?xml version="1.0" encoding="utf-8"?> 
<TabHost 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:padding="5dp"> 
     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 
     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:padding="5dp" /> 
    </LinearLayout> 
</TabHost> 

但在底部标签栏,我们使用

**

<?xml version="1.0" encoding="utf-8"?> 
<TabHost 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <RelativeLayout 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent"> 
     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_alignParentBottom="true" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" /> 
     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:padding="5dp" /> 
    </RelativeLayout> 
</TabHost>** 

最主要的是

android:layout_alignParentBottom=”true”; 
1

我用这个布局用于查找bo中的Tabs屏幕TTOM:

?xml version="1.0" encoding="utf-8"?> 
<TabHost 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/tabhost" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <FrameLayout 
      android:id="@android:id/tabcontent" 
      android:layout_width="0dp" 
      android:layout_height="0dp" 
      android:layout_weight="0"/> 
     <FrameLayout 
      android:id="@+android:id/realtabcontent" 
      android:background="@drawable/bg_main_app_gradient" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1"/> 
     <TabWidget 
      android:id="@android:id/tabs" 
      android:background="#EAE7E1" 
      android:orientation="horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_weight="0"/> 
    </LinearLayout> 
</TabHost> 

的代码examle:https://stackoverflow.com/a/23150258/2765497

0

我碰到你的问题寻求做同样的事情,然而,根据机器人发展的指导方针,你不应该曾经有一个在底部的标签栏,因为这是一个iOS的功能...

Android Development Standards

+0

有趣的是,他们自己的Gmail应用程序曾经在底部有菜单 – Han

0

你似乎有底部栏有点糊涂。这不是标签栏。底部栏是用于操作,而不是导航屏幕。例如,在上面发布的Gmail应用的屏幕截图中,底部栏允许用户:撰写电子邮件,搜索,标记,刷新等。参考:

从技术上讲,这些按钮可以将用户导航到其他屏幕,但标签栏通常用于“切换”屏幕。例如按类别查看内容。

嗯,但在Gmail应用程序的最新版本中,它们上面有这些操作按钮。叹息...

+0

虽然这个链接可能回答这个问题,但最好在这里包含答案的重要部分并提供参考链接。如果链接页面更改,则仅链接答案可能会失效。 –

+0

感谢您的提示。该链接仅供参考。 – Vasim

1

谷歌不建议在底部有制表符。

于Android请参见下面的官方设计模式引导,
并查找节“不要使用底部标签栏”

http://developer.android.com/design/patterns/pure-android.html

+0

不,虽然这是Android/Google推荐的,但这对布局设计师来说听起来很荒谬。毕竟,使用标签并不是很糟糕。 – Raptor

+5

最新的Google+应用程序在屏幕底部有标签,与文档中说不应该使用的方式完全相同。 – moyheen

+3

http://www.theverge.com/2016/3/15/11236152/material-design-update-bottom-navigation-bar –

1

我想在这里发布更新。 Bottom nav bars are now Android Canon.由此得到的主要结果是:

1)使用底部导航栏只能用于3-5个图标。更少,请使用tabs。再者,使用可滚动的选项卡(在同一链接上的页面)。

2)避免使用底部的导航栏和标签,并确保两者的责任是明确分开,如果你这样做。

3)底部NAV杆应该用于导航动作(使用ActionBar那些)