android - 添加类似于 iOS 设备工具栏的底部工具栏

标签 android

有没有办法在Android的底部添加一个工具栏,类似于iOS设备上的工具栏?

enter image description here

最佳答案

您可以在布局中使用工具栏来根据需要制作页脚:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <!-- // Main content comes here  -->

    <!-- Footer -->
    <RelativeLayout android:id="@+id/footer"
                android:layout_width="fill_parent" android:orientation="horizontal"
                android:layout_alignParentBottom="true"
                android:layout_height="wrap_content">
        <LinearLayout
            android:layout_height="?attr/actionBarSize"
            android:layout_width="match_parent"
            android:orientation="vertical">

            <include layout="@layout/toolbar"/>

        </LinearLayout>

    </RelativeLayout>
</RelativeLayout>

添加 toolbar.xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
   xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   android:background="?attr/colorPrimary"
   android:minHeight="@dimen/abc_action_bar_default_height_material">

  <!-- One can customize it as much as he wants, for showing an example,
       I have shown below how to add an image at the center of toolbar-->

  <ImageView
    android:layout_width="wrap_content"
    android:contentDescription="@string/logo"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:src="@drawable/ic_launcher"/>

</android.support.v7.widget.Toolbar>

关于android - 添加类似于 iOS 设备工具栏的底部工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27551654/

相关文章:

android - 左右声道与麦克风录音分离

android - 媒体 Controller 隐藏但媒体播放器继续播放

Android展开 View 动画

android - Ionic Cordova Android : No usable Android build tools found. 最高 30.x 安装版本为 30.0.2;所需的最低版本是 30.0.3

java - Android 上的自动启动 Kodi 应用程序

android - 协程中的 HandlerThread 替换

Android:多个textview就像单个文本

android - 使用 Async Task 和 BaseAdapter 解析 Json

java - 使用 Java 进行 Android 图像编辑/变形?

android - View 未显示在relativeLayout中