android - Align Toolbar icons from right to left? -
in application, have implemented languages including arabic language starts right left. want align icons in toolbar right_to_left
.
i tried layout_gravity="right"
, gravity="right"
nothing happed.
my toolbar code:
<android.support.v7.widget.toolbar xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/primary_color" app:popuptheme="@style/theme.appcompat.light"/>
here want:
official right-to-left support introduced android 4.2 (api level 17), work if minimum sdk level 17:
1) put android:supportsrtl="true"
attribute in androidmanifest file support right-to-left layout directions.
2) secondly put code in activity's oncreate() methdod:
if (getwindow().getdecorview().getlayoutdirection() == view.layout_direction_ltr){ getwindow().getdecorview().setlayoutdirection(view.layout_direction_rtl); }
this make placed right left if system uses according language. make sure use start/end instead of left/right when setting padding make sure elements aligned correctly.
for more information official support announcement: http://android-developers.blogspot.be/2013/03/native-rtl-support-in-android-42.html
Comments
Post a Comment