Search code examples
androidxamarinxamarin.androidandroid-custom-viewandroid-6.0-marshmallow

Why won't the child views of my custom view render in Marshmallow?


I'm developing a custom keyboard using Xamarin.

My keyboard view has an overridden OnDraw() for both the view container itself and it's child key views. I'm also using SetWillNotDraw(false) appropriately for each view. It currently works beautifully in 5.0.1 on my Nexus 10 tablet.

In Android 6.0.1, on a Nexus 6 and a Nexus 6P, the keyboard view correctly draws itself (just a background color). The child key views however are never drawn, even if I iterate through the view hierarchy and force an invalidate on each one. This seems to be specific to Marshmallow.

I don't know if there's something new I need to account for in this version of Android or if I'm encountering a bug.

Any help or suggestions are welcome.

Code:

KeyboardView

KeyView


Solution

  • Fixed by properly implementing OnMeasure and OnLayout for each custom view through the top-down approach suggested by Android documentation.