2

Does anyone know if ViewCompat.setLayoutDirection works in API level below 17?

I search for a solution all over the internet but I can't find a solid one.

Greg
  • 18,111
  • 5
  • 46
  • 68
gil cohen
  • 333
  • 2
  • 8
  • 21
  • Possible duplicate of [How to handle RTL languages on pre 4.2 versions of Android?](http://stackoverflow.com/questions/15746091/how-to-handle-rtl-languages-on-pre-4-2-versions-of-android) – Charuක Dec 22 '16 at 16:07

1 Answers1

3

setLayoutDirection was added to in API Level 17 (read here) which is 4.2 so the older versions do not support that. So keep two layouts for higher and below and you need to work around for the below api level XML view.

If you're using the support library, you can do the following:

if (ViewCompat.getLayoutDirection(view) == ViewCompat.LAYOUT_DIRECTION_RTL) {
    //  view -RTL layout
} else {
    //view -  set made layout for below apis 
}

BidiFormatter might help you depending on your requirement.Check that as well.

Every one knows about android:layout_gravity="end" right? can be helpfull in this case

Charuක
  • 12,953
  • 5
  • 50
  • 88