Yes, itβs absolutely possible, you just need to hide the default toolbar by doing the following Styles.xml :
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
Then you need to create your own XML toolbar file to name it custom_toolbar.xml
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" app:contentInsetLeft="0dp" app:contentInsetStart="0dp"> <ImageView android:id="@+id/back_button" android:background="@drawable/back_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <ImageView android:id="@+id/menu_button" android:background="@drawable/menu_icon" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/toolbar_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginRight="10dp" android:textColor="@android:color/black" android:textSize="@dimen/actionbar_textsize" android:textStyle="bold" /> </android.support.v7.widget.Toolbar>
Then you should add this toolbar to your add toolbar as shown below
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="betasoft.com.blankblank.ui.ui.activity.SignUp"> <include android:id="@+id/toolbar" layout="@layout/custom_toolbar" /> <FrameLayout android:id="@+id/main_data" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/toolbar /> </RelativeLayout>
then you can access the toolbar in your activity, for example:
Toolbar mToolBar; ImageView mToolBarBack,mToolBarMenu; TextView mToolBarTitle;
// then create a public method as shown below so you can access the contents of the toolbar in any snippet
public void setActionBarTitle(String title) { mToolBarTitle.setText(title); }
source share