SKGLView 比 SKCanvasView 暗得多

SKGLView much darker than SKCanvasView

我的应用程序的主屏幕是通过 SKCanvasView 呈现的。颜色准确地反映了我在代码中指定的值。

如果我换入 SKGLView(硬件加速版本),不更改其他代码,结果会变暗 60%:

    <!--<skia:SKCanvasView PaintSurface="OnCanvasViewPaintSurface" />-->
    <skia:SKGLView PaintSurface="OnCanvasViewPaintSurface" />

为什么会发生这种情况,我该如何解决?

答案可以在这里找到:https://github.com/mono/SkiaSharp/issues/299#issuecomment-331990904

I found the solution to the problem. There is a specific attribute that is set in the splash screen style, but is not unset (for some reason) when the style is changed.

In the splashscreen style, note this:

<item name="android:backgroundDimEnabled">true</item>

Docs: https://developer.xamarin.com/api/field/Android.Resource+Attribute.BackgroundDimEnabled

This is not unset when the style is switched. So, to fix this, just set it to false:

<item name="android:backgroundDimEnabled">false</item>

Here is a repository that demonstrates this: https://github.com/mattleibow/AndroidGLSurfaceViewTests