0

I'm trying to get the layout direction in Xamarin Android from this java code:

resource.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;

I tried to make this code:

Android.Util.LayoutDirection.Rtl == Android.Views.LayoutDirection.Rtl;

But it doesn't Work. I get the error: enter image description here

I'm tryin to implement this code in xamarin Android (from shnizlon's answer):

Implementing SearchView as per the material design guidelines

JotaPardo
  • 817
  • 9
  • 27

2 Answers2

1

try this

if (this.Resources.Configuration.LayoutDirection == LayoutDirection.Rtl) 
Jason
  • 86,222
  • 15
  • 131
  • 146
0

According to the shnizlon's answer, I used the context variable and the Android.Content.Res.Resources namespace for the input variable of the isRtl method.

In Java:

private boolean isRtl(Resources resources) {
    return resources.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
}

In C# (Xamarin Android):

private bool isRtl(Android.Content.Res.Resources resources)
{
     return resources.Configuration.LayoutDirection == Android.Views.LayoutDirection.Rtl;
}
JotaPardo
  • 817
  • 9
  • 27