-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Open
Description
When the Title text is a RTL-language text the Icon remain in Left side of Title panel while I expect title layout follow the direction of title text. i.e. if text is RTL then Title panel layout direction become RTL as well. i.e. Icon in Right of the Title Text
Describe the solution you'd like
I suggest add an extra attribute "auto" (or "content") for layoutDirection. i.e.
<attr name="layoutDirection">
<!-- Left-to-Right. -->
<enum name="ltr" value="0" />
<!-- Right-to-Left. -->
<enum name="rtl" value="1" />
<!-- Inherit from parent. -->
<enum name="inherit" value="2" />
<!-- Locale. -->
<enum name="locale" value="3" />
<!-- follow text direction. ****************** NEW ***************** -->
<enum name="auto" value="4" />
</attr>
and check if the first char of Title text is RTL or LTR and set the panel direction accordingly:
int direction = getLayoutDirectionFromFirstChar();
String title = getTitle();
private int getLayoutDirectionFromFirstChar() {
switch (Character.getDirectionality(title.charAt(0))) {
case Character.DIRECTIONALITY_RIGHT_TO_LEFT:
case Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC:
return ViewCompat.LAYOUT_DIRECTION_RTL;
case Character.DIRECTIONALITY_LEFT_TO_RIGHT:
default:
return ViewCompat.LAYOUT_DIRECTION_LTR;
}
}
if(attr value ==4) {
getTitlePanel().setLayoutDirection(direction)
}