0

I am trying to show a dialog at the right top corner of the screen with the following line in my Activity class:

dialog.getWindow().getAttributes().gravity= Gravity.RIGHT|Gravity.TOP

This works fine. But when i checked the code for any inconsistency by running Lint on my project it shows a suggestion stating

Use "'Gravity.END'" instead of "'Gravity.RIGHT'" to ensure correct behavior in right-to-left locales

My question: What is the difference between Gravity.END and Gravity.RIGHT and what does right-to-left locales mean?
TIA

Alvi
  • 767
  • 8
  • 20

2 Answers2

1

You may not use gravity="right", but gravity="end" instead, the same idea you apply to gravity="left" which you may use gravity="start", as well as layout_marginStart instead of layout_marginLeft. Android will put the text to the "start" orientation, depending on the location. (for many of us, we start to write from the left and we end on the right, but arabians start from the right and end on the left).

Read more about this here

1

According to this issue tracker, it is a bug which was fixed in Android Studio 0.8.10 recently.

The option to disable this inspection can be found under Project Settings | Inspections | Android Lint | Unsing left/right instead of start/end attributes. So you can simply disable it for the whole project by unchecking the box.

Harshal Benake
  • 2,391
  • 1
  • 23
  • 40