Search code examples
xamarinxamarin.formsxamarin.android

Disable defaultFocusHighlightEnabled in the android part for a Xamarin.Forms application


In a xamarin.forms application running in an android 8 device I want to disable the controls highlights when I'm using a physical keyboard (this is a new android 8 behavior)

The android documentation says that I should set android:defaultFocusHighlightEnabled="false" for that

I tried to add that in my manifest file but the highlight continues appearing

<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:defaultFocusHighlightEnabled="false" android:versionName=

Where can I set that globally?


Solution

  • I was able to solve the issue with the comments

    In my styles.xml file (referenced in the main activity) I added the entry in the theme

    MainActivity.cs

    [Activity(Label = "Sage Service Ops", Icon = "@drawable/icon", MainLauncher = false, Theme = "@style/MyTheme", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
    

    styles.xml

    <style name="MyTheme" parent="@android:style/Theme.Holo.Light">
      <item name="android:actionBarStyle">@style/MyTheme.ActionBarStyle</item>
      <item name="android:defaultFocusHighlightEnabled">false</item>
    </style>