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

2

There are 2 best solutions below

0
Jason On BEST ANSWER

try this

if (this.Resources.Configuration.LayoutDirection == LayoutDirection.Rtl) 
0
Jota Pardo On

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;
}