是否可以在Android底部添加工具栏,类似于iOS设备上的工具栏。
答案 0 :(得分:3)
您可以在布局中使用工具栏根据需要制作页脚:
<?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>
答案 1 :(得分:1)