0

Android Oreo introduces text justification in Text View.

I created a custom renderer for Label and add the following in Visual Studio 15.6.6.

    if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
    {
      textview.SetJustificationMode(JUSTIFICATION_MODE_INTER_WORD);
    }

However, VS says Text View does not contain a definition for SetJustificationMode.

I have installed Android 8.0 (API26) and Android 8.1 (API27) SDK.

Any assistance is much appreciated. Thanks.

Tek Mun
  • 97
  • 9
  • Did you also set the target framework to the right API version that supports this? You can do so in you project properties of the Droid project – Gerald Versluis May 03 '18 at 11:02
  • Yes. Under Application, Compile using Android Version (Target Framework) is Android 8.1 (API27). Under Android Manifest, Minimum Android Version is Android 5.1 (API22) and Target Android Version is Android 8.1 (API27). – Tek Mun May 03 '18 at 11:24

1 Answers1

0

The method setProperty(...) may be mapped to the property Property in Xamarin.Android.

Example:

TextView textview = new TextView(Context);

if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.O)
{
  textview.JustificationMode = Android.Text.JustificationMode.InterWord;
}

Using Visual Studio, the metadata of TextView can be accessed with "Go To Definition (F12)".

Example:

...

public class TextView : View, ViewTreeObserver.IOnPreDrawListener, IJavaObject, IDisposable

...

public virtual JustificationMode JustificationMode { get; set; }

...

Community
  • 1
  • 1
Benl
  • 2,777
  • 9
  • 13
  • Thanks for the answer. Yes, I managed to set JustificationMode to InterWord now. However, the text display is still not full justification. (It looks different compared to without JustificationMode.InterWord but it is not full justification.) – Tek Mun May 05 '18 at 02:01