grantespo
grantespo

Reputation: 2269

How to Replace Action Bar's Text with multiple buttons

I have something like this in my app:

enter image description here

How do I replace the text with buttons so it looks something like this:

enter image description here

Upvotes: 0

Views: 95

Answers (2)

Dhaval Solanki
Dhaval Solanki

Reputation: 4705

You can take custom toolbar and put all the images in toolbar, This is best way like following.

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

Set Activity theme as AppTheme.NoActionBar theme like

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

and then after dynamicaly set Toolbar in activity and access all the Image like button.

And one another way is take TabLayout for this.

Upvotes: 0

Krupa Kakkad
Krupa Kakkad

Reputation: 857

1.Remove your action bar. Add below code in your manifest application tag

<android:theme="@android:style/Theme.NoTitleBar"> 
  1. Use tab layout. For more information: https://developer.android.com/reference/android/support/design/widget/TabLayout.html Example of tab layout: http://www.androidhive.info/2015/09/android-material-design-working-with-tabs/

Upvotes: 2

Related Questions