如何用多个按钮替换操作栏的文本

How to Replace Action Bar's Text with multiple buttons

我的应用程序中有这样的东西:

如何用按钮替换文本,使其看起来像这样:

1.Remove 你的操作栏。 在清单应用程序标签中添加以下代码

<android:theme="@android:style/Theme.NoTitleBar"> 
  1. 使用选项卡布局。 更多信息:https://developer.android.com/reference/android/support/design/widget/TabLayout.html 选项卡布局示例: http://www.androidhive.info/2015/09/android-material-design-working-with-tabs/

您可以采用自定义工具栏并将所有图像放在工具栏中,这是最好的方法。

<android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        app:popupTheme="@style/AppTheme.PopupOverlay">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/logo_1" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/logo_1" />

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

将Activity主题设置为AppTheme.NoActionBar主题,如

android:theme="@style/AppTheme.NoActionBar"

然后在 activity 中动态设置工具栏并访问所有图像按钮。

另一种方法是为此使用 TabLayout。