【问题标题】:Add icons in the bottom of the screen在屏幕底部添加图标
【发布时间】:2015-10-06 13:28:55
【问题描述】:

这个叫什么名字?如何设计它?任何有效的有用教程示例?

【问题讨论】:

  • 很可能是水平线性布局
  • 为此使用选项卡主机
  • 我称之为footer。它可以是任何布局(不一定是线性)或任何视图(甚至是自定义视图)。
  • @Sadiq 什么是标签主机
  • @Baalback 请点击此链接envyandroid.com/align-tabhost-at-bottom

标签: android


【解决方案1】:

这在android中称为split action bar

拆分操作栏在屏幕底部提供了一个单独的栏 当活动在窄幅上运行时显示所有操作项 屏幕(例如面向纵向的手机)。

显示带有标签的操作栏(左)的模型,然后是拆分 操作栏(中);并禁用应用图标和标题(右)。

更新:

在较新的 UI 模式中,它被称为 bottom toolbar

启动到架子的底部工具栏和 紧贴键盘顶部或其他底部组件

请参考this question 来创建一个。


注意:android 在其 UI 元素中没有用于操作的带有图标的文本,有问题的屏幕截图似乎是一个混合应用程序,并且答案中的建议最接近原生应用程序的默认 UI 模式支持。

【讨论】:

  • 截图中显示的不是拆分操作栏。例如,拆分操作栏在图标下方没有标题。
  • @CommonsWare 是的,错过了文本。但是它们都是动作而不是选项卡。
  • 工具栏不支持拆分操作栏。
  • 我仍然对此表示赞同。真的不知道它的存在。
  • 拆分操作栏最接近显示的模式。不建议将此模式用于标签。
【解决方案2】:

是的,您可以使用线性布局。想要什么都行,只要好看就行。

诀窍是让它粘在屏幕底部。我喜欢在相对布局中包含所有内容,并将线性布局设置在相对布局中,并使其与父级的底部对齐。

示例布局:

<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>

android:layout_alignParentBottom="true" 是这里的重要部分,但还有其他方法可以使线性布局保持在底部。

【讨论】:

  • 你知道这方面的例子吗?
  • 您可以在示例中添加带有文本的虚拟图像吗?
  • 我发布的布局基本上是将三个按钮放入绑定到屏幕底部的线性布局中。你将不得不付出更多的努力来美化它。
【解决方案3】:

你可以这样做在底栏中添加按钮:

<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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-24
    • 1970-01-01
    • 1970-01-01
    • 2021-12-28
    • 1970-01-01
    • 1970-01-01
    • 2019-05-02
    • 2021-06-23
    相关资源
    最近更新 更多