First of all remove the default ActionBar
edit your style.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme colors here. -->
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
<!-- Disables the Default ActionBar -->
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
Then in your main_activity_layout.xml, remove any padding on the root RelativeLayout tag.
Next
<android.support.v7.widget.Toolbar
android:id="@+id/mainToolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageButton
android:id="@+id/main_settings_btn"
android:background="@drawable/ic_settings"
android:backgroundTint="@color/accent"
android:contentDescription="Copy"/>
<ImageButton
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:background="@drawable/ic_points"
android:backgroundTint="@color/accent"
android:contentDescription="Paste"/>
</android.support.v7.widget.Toolbar>
...... <your_code_here_possibly_recyclerview>
This solves your extra toolbar issue.
Next
private Toolbar toolbar; // Declaring the Toolbar Object
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar = (Toolbar) findViewById(R.id.mainToolbar); // Attaching the layout to the toolbar object
setSupportActionBar(toolbar); // Setting toolbar as the ActionBar with setSupportActionBar() call
// Now whenever you want to update the title just change text in below
getSupportActionBar().setTitle("My title");
}