Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Actionbar back arrow direction

In my application I started to set the UI to meet Material Design use the Toolbar.

I want to add the back arrow on the action bar. It looks ok but somehow, when I change my phone locality to Hebrew which is a rtl language, the arrow change it's direction and instead of pointing "out", it is now pointing "in". Please refer to image to see how arrow looks in Hebrew and English. Is there a way to control the arrow direction (I want it will point "out" always of course)?

I tried to add the android:layoutDirection="ltr" and android:textDirection="ltr" but it didn't helped.

Thanks for who can answer on this.

enter image description here

Here is the code of the Toolbar layout:

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="@color/primaryColor"
app:theme="@style/MyCustomToolBarTheme"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"
android:textDirection="ltr"
android:layoutDirection="ltr">

like image 603
Moti Bartov Avatar asked Jan 08 '23 02:01

Moti Bartov


2 Answers

Finally I succeeded to change the arrow direction.

Well, actually I followed this post: First, I have found some action bar icons and placed a drawable back icons in the project. Then I used this code to set the arrow programmatically:

        getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_action_back);
like image 162
Moti Bartov Avatar answered Jan 21 '23 03:01

Moti Bartov


The "back" icon is provided by a drawable specified in the homeAsUpIndicator attribute of the theme. You can try to override it and put your own marker (arrow out) it would be something like this:

<style name="Theme.MyTheme" parent="android:Theme.Holo">
    <item name="android:homeAsUpIndicator">@drawable/out_arrow</item>
</style>
like image 29
Nicolas Avatar answered Jan 21 '23 02:01

Nicolas