Here are your options:
1. It doesn't seem like you need a toolbar here at all. You can remove it from your XML file and add this line
getSupportActionBar().hide();
in MyActivity.java instead
if (toolbar != null) { setSupportActionBar(toolbar); }
2. If you want to save the toolbar if you use it later, you can hide it in any xml file
<android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:visibility="gone" android:background="?attr/colorPrimary"/>
or in MyActivity.java after setting the toolbar as a support action bar
if (toolbar != null) { setSupportActionBar(toolbar); } toolbar.setVisibility(View.GONE);
iamkaan
source share