FloatingActionButton
FloatingActionButton copied to clipboard
RTL support
Have you been thinking about adding support for RTL (Right-to-Left) languages? I'm using your library and it's great. Now my users wanted support for RTL languages (Arabic etc...). The FAB from Google Support Deisign library is working great here. If you are using RTL language on your phone the FAB is on the left.
Your library is always showing button on the right side (which is wrong).
Or maybe I miss something. Settings layout_gravity is not working.
The problem is with FAB with menu.
Did you try to change "fab:menu_labels_position" value on your layout : By defaulft, it's left but if you change the value to right (fab:menu_labels_position="right"), that's solve your problem, no?
@jndefosse No. Not at all. Layout should use these features: http://android-developers.blogspot.com/2013/03/native-rtl-support-in-android-42.html
If you try to create layouts for RTL languages you'll see how this works.
FAB from Design Support Library works great.
I think that this should be part of the library. If users is using RTL layout FAB should be moved by default to let.
I set app:menu_labels_position="right" and app:layout_anchor="@id/vpPager" app:layout_anchorGravity="bottom | left | start"
and everything is right in RTL language.
simple fix in FloatingActionMenu i put this
public static boolean isRTL() {
return isRTL(Locale.getDefault());
}
public static boolean isRTL(Locale locale) {
final int directionality = Character.getDirectionality(locale.getDisplayName().charAt(0));
return directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT ||
directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC;
}
then in init
if (isRTL()) {
mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_RIGHT);
} else {
mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_position, LABELS_POSITION_LEFT);
}
in my fork https://github.com/amorenew/FloatingActionButton
You can add to integer resources value with the position. LTR languages:
<resources>
<integer name="fab_menu_position">0</integer>
</resources>
RTL languages:
<resources>
<integer name="fab_menu_position">1</integer>
</resources>
then in FloatingActionMenu:
app:menu_labels_position="@integer/fab_menu_position"
How can set it programetically ? because if arabic then it is display in right other wise i want to disply on left side
@dawidhyzy i have tried you mention sorry but it is not work for me
@mehulTank what you mean by parametrically?