5
votes

I have custom renderer for a Xamarin Forms Frame :CustomFrameRenderer. A sample Xaml is below

<controls:ExtendedFrame Margin="2,0,2,0"
                                    BackgroundColor="Red"
                                    HorizontalOptions="FillAndExpand"
                                    OutlineColor="Red"
                                    Padding="0,0,0,0">
<Label Text="This is a test"/>
</controls:ExtendedFrame>

The problem is, if I bind the bacground color to a property like this,

 <controls:ExtendedFrame Margin="2,0,2,0"
                                    BackgroundColor="{Binding FrameBackground}"
                                    HorizontalOptions="FillAndExpand"
                                    OutlineColor="{Binding FrameBackground}"
                                    Padding="0,0,0,0">

The frame get's it's color updated based on an item selected in a ListView. Now, if I use the standard Frame it works perfectly fine. But I use my custom frame with rounded corners, I get this error in Android.

Java.Lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isMutable()' on a null object reference

Any help is appreciated.

1
I did not reproduce the issue. I have written a demo for your question, it should be helpful. - Mike Ma
@Madhav Did you find any solution ? Can I get a look at your custom renderer ? I am using a converter to change the Outline color based on a property... And the rounded corner frame is inside a listview. All the items displayed initially on screen have the RoundedCornerFrame rendered properly...however, when I scroll down, I get the same Java.Lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isMutable()' on a null object reference exception - b.g

1 Answers

0
votes

Even i had the same issue with frame control, in my case resolved this issue by changing the base class of my android project custom renderer to "Visual Element" of type "Frame" instead of "Xamarin.Forms.Platform.Android.FrameRenderer". For more detail check my blog update http://www.appliedcodelog.com/2017/12/bug-javalangnullpointerexceptionattempt.html