在android中创建底部工具栏的最佳方法.

Ved*_*wal 13 layout android material-design

示例工具栏

寻找一种实现类似工具栏的好方法.我应该使用图像按钮吗?

Ell*_*ltz 12

<android.support.v7.widget.Toolbar  xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/actionbarT"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/thebackgroundimageyouwant"
android:minHeight="?attr/actionBarSize"
app:theme="@style/Base.Theme.AppCompat.CompactMenu" >

    <LinearLayout
        android:id="@+id/toolbarmenucontainer"
        android:layout_width="match_parent"
        android:weightSum="3"
        android:layout_height="match_parent"
        android:orientation="horizontal" >

        <ImageButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="@drawable/preferedbackground"
            android:clickable="true"
            android:scaleType="fitXY"
            android:layout_weight = "1"
            android:src="@drawable/preferredimage" />

         <ImageButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="@drawable/preferedbackground"
            android:clickable="true"
            android:scaleType="fitXY"
            android:layout_weight = "1"
            android:src="@drawable/preferredimage" />

        <ImageButton
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="@drawable/preferedbackground"
            android:clickable="true"
            android:scaleType="fitXY"
            android:layout_weight = "1"
            android:src="@drawable/preferredimage" />

    </LinearLayout>

</android.support.v7.widget.Toolbar>
Run Code Online (Sandbox Code Playgroud)

这个想法是他们会像你想要的那样水平布局,也就是不做ToolBar.setTitle()或者ToolBar没有设置,你也不必添加选项菜单.所以它会像你想要的那样裸露.

尝试它,看看它是否符合您的要求,记得将背景和图像src添加到ImageButtons


Ale*_*.B. 6

我知道这个问题已经超级老了,但我认为为其他人寻求同样的事情回答永远不会太晚.我刚刚发现本教程这些关于该主题的官方文档,现在底部导航由Android正式支持,如果您的应用具有3到5个顶级导航位置,则它们是材料设计指南的一部分.我希望这有助于其他人,因为我花了很多时间环顾四周.

  • 感谢您提供的链接,我知道Android支持底部工具栏,但我很难找到它。 (2认同)