Add LinearLayout to the other side of your toolbar like this.
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_transaction"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#F6F6F6"
app:popupTheme="@style/AppTheme.PopupOverlay" >
<LinearLayout
android:id=@+id/toolbar_item_container
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" />
</android.support.v7.widget.Toolbar>
and then in the Java file access this line, for example,
Toolbar mToolbar = (Toolbar)findViewById(R.id.toolbar_transaction);
LinearLayout layoutToolbar = (LinearLayout)mToolbar.findViewById(R.id.toolbar_item_container);
Now using this layoutToolbar add or remove any view from it
layoutToolbar.addView(); and layoutToolbar.removeView();
source
share