2013-09-22 61 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那些)