XF 3.5 - ScrollViewRenderer throws error when setting ScrollView properties

DannyNDannyN USUniversity ✭✭

In XF 3.4, this code works perfectly for setting ScrollView properties in the ScrollViewRenderer.
`protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);

    if (this.Element == null)
        return;

        global::Android.Widget.ScrollView droidScrollView = (global::Android.Widget.ScrollView)this;

        droidScrollView.HorizontalScrollBarEnabled = false;
        droidScrollView.VerticalFadingEdgeEnabled = true;
        droidScrollView.SetFadingEdgeLength(70);
        droidScrollView.VerticalScrollBarEnabled = true;
        droidScrollView.ScrollbarFadingEnabled = false;
    }   

`

In XF 3.5, the cast i did to a ScrollView no longer works b/c the renderer no longer inherits from ScrollView. It now inherits from NestedScrollView. I'm not sure if this is the reason for the problems. Anyway, the new code is below but throws an exception at runtime.
`protected override void OnElementChanged(VisualElementChangedEventArgs e)
{
base.OnElementChanged(e);

        if (this.Element == null)
        return;

        this.HorizontalScrollBarEnabled = false;
        this.VerticalFadingEdgeEnabled = true;
        this.SetFadingEdgeLength(70);
        this.VerticalScrollBarEnabled = true;
        this.ScrollbarFadingEnabled = false;
    }   

`

Here is the exception that is thrown
Java.Lang.RuntimeException: Attempt to invoke virtual method 'android.widget.ScrollBarDrawable android.widget.ScrollBarDrawable.mutate()' on a null object reference

I also tried to install the pre release of XF 4.0 but the problem remained.

For now, I will continue running XF 3.4. If anyone has insight into a solution for this, please let me know. Thanks!

Posts

Sign In or Register to comment.