Reputation: 386
Is there any tutorial easy to understand to create a toolbar with the home button aligned to the left and the log out button aligned to the right?
I am using menu type .xml files to do it, but I am not able to align the buttons as I want.
My .xml is:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/etxera"
android:icon="@drawable/etxera_fondo"
android:title="Hasierara"
app:showAsAction="always" />
<item android:id="@+id/saioa_itxi"
android:icon="@drawable/saioaitxi"
android:title="saioa itxi"
app:showAsAction="ifRoom" />
</menu>
Thanks for support!
Upvotes: 0
Views: 93
Reputation: 81
Make a custom toolbar
toolbar.xml
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:titleTextColor="#FFFFFF">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/left_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left" />
<Button
android:id="@+id/right_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
Include the toolbar into your main_activity.xml
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
</RelativeLayout>
Don't forget to set the NoActionBar theme
Upvotes: 1