2015-10-06 125 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>