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>
Pragmatically add back button in java file (in Activity
)
Try this
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle("Divine");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With