2015-10-06 123 views
2

這是什麼名字?如何設計它?任何有效的有用教程示例?在屏幕底部添加圖標

enter image description here

+2

它最有可能是水平的LinearLayout – thumbmunkeys

+0

使用Tab主機此 – Sadiq

+0

我把它叫做'footer'。它可以是任何佈局(不一定是線性)或任何視圖(甚至是自定義的)。 –

回答

5

這在稱爲split action bar機器人

拆分操作欄提供在屏幕 底部的單獨條時顯示活性的窄 屏幕上運行的所有行動項目(如面向肖像的手機)。

splitactionbar

實物模型顯示用突片(左)的操作杆,然後用分裂 動作條(中間);並禁用了應用圖標和標題(右圖)。

更新:

在新的UI模式被稱爲bottom toolbar

bottomtoolbar一個啓動的貨架底部的工具欄和 攀附着鍵盤或其他底層組件的頂部

請參閱this question來創建一個。


注:Android不具有在其行動UI元素圖標的文字,截圖中的問題似乎是一個混合應用程序,並在回答的建議是最近由本機應用程序的默認UI模式的支持。

+2

截圖中顯示的內容不是拆分操作欄。例如,分割操作欄在圖標下方沒有標題。 – CommonsWare

+0

@CommonsWare是的,錯過了文字。然而,所有這些都是行爲而不是標籤。 –

+1

工具欄不支持拆分操作欄。 – Sadiq

3

是的,你可以使用線性佈局。無論你想要什麼,只要你讓它看起來不錯。

訣竅是讓它堅持到屏幕的底部。我喜歡在相對佈局中包含所有內容,並在相對佈局內設置線性佈局,並使其與父級的底部對齊。

例如佈局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       xmlns:tools="http://schemas.android.com/tools" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"> 


    <LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true"> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="New Button" 
      android:id="@+id/button1"/> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="New Button" 
      android:id="@+id/button2"/> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="New Button" 
      android:id="@+id/button3"/> 
    </LinearLayout> 
</RelativeLayout> 

機器人:layout_alignParentBottom =「true」是這裏的重要組成部分,但也有其他辦法,使底部的線性佈局的住宿。

+0

你知道這個例子嗎? – Baalback

+0

編輯我的文章,包括一個例子 – BooleanCheese

+0

你可以在你的例子中添加虛擬圖像與文本? – Baalback

2

你可以做這樣的事情加在底部欄按鈕:

<LinearLayout android:id="@+id/footer" android:layout_width="fill_parent" 
    android:layout_height="wrap_content" android:orientation="horizontal" 
    android:layout_alignParentBottom="true" style="@android:style/ButtonBar"> 

    <Button android:id="@+id/saveButton" android:layout_width="wrap_content" 
     android:layout_height="wrap_content" android:layout_weight="1" 
     android:text="@string/menu_done" /> 

    <Button android:id="@+id/cancelButton" android:layout_width="wrap_content" 
     android:layout_height="wrap_content" android:layout_weight="1" 
     android:text="@string/menu_cancel" /> 
</LinearLayout>