Create custom toolbar (toolbar.xml), you can use LinearLayout
to house your custom design:
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="100dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
Include custom toolbar into your activity.xml:
<include
android:layout_width="fill_parent"
android:layout_height="wrap_content"
layout="@layout/toolbar" />
To access Button
:
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//Your logic
}
});