Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to align icon on the left side of the app bar in android

I am trying to push the back icon image on the left side of the app bar in the android but the icon displaying in the middle of app(tool) bar. How to align icon on the right side of the app bar in android? Please have a look at the image below.

<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="divine.calcify.activities.HomeScreenActivity">
    <item
        android:layoutDirection="ltr"
        android:id="@+id/hs_back_button"
        android:icon="@mipmap/ic_back"
        android:title="@string/homescreen_back"
        app:showAsAction="always"
        ></item>
    <item
        android:id="@+id/menu_search"
        android:icon="@mipmap/ic_search"
        android:title="@string/homescreen_search"
        android:orderInCategory="1"
        app:showAsAction="always"
        app:actionViewClass="android.support.v7.widget.SearchView"/>
    <item android:id="@+id/menu_notifications"
        android:icon="@mipmap/ic_divine_notification"
        android:title="@string/homescreen_notification"
        android:orderInCategory="2"
        app:showAsAction="always" />
</menu>

enter image description here

like image 233
Mithun Kumar Avatar asked Aug 08 '16 09:08

Mithun Kumar


1 Answers

Pragmatically add back button in java file (in Activity)

Try this

 ActionBar actionBar = getSupportActionBar();
 actionBar.setDisplayHomeAsUpEnabled(true);
 actionBar.setTitle("Divine");
like image 119
Vishwesh Jainkuniya Avatar answered Oct 04 '22 11:10

Vishwesh Jainkuniya