0

While working on page rendering in the Xamarin I am encountering the app crash when OnLayout is called. The view.Measure(msw,msh) is throwing null exception.

protected override void OnLayout(bool changed, int l, int t, int r, int b)
{
    base.OnLayout(changed, l, t, r, b);

    var msw = MeasureSpec.MakeMeasureSpec(r - l, MeasureSpecMode.Exactly);
    var msh = MeasureSpec.MakeMeasureSpec(b - t, MeasureSpecMode.Exactly);

    view.Measure(msw, msh);
    view.Layout(0, 0, r - l, b - t);
}

`

Andrew
  • 1,390
  • 10
  • 21
  • `...throwing null exception...` Are you saying `view` is null? Where are you assigning it... https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it?rq=1 – SushiHangover Oct 02 '18 at 02:45
  • Sorry I meant "Object reference not set to an instance of an object" this. I am assigning view = LayoutInflater.From(this.Context).Inflate(Resource.Layout.CameraLayout, this, false); –  Oct 02 '18 at 03:08
  • 1
    Sounds like your LayoutInflater.From is returning null. – SushiHangover Oct 02 '18 at 03:49
  • Are you using a fragment? – FreakyAli Oct 03 '18 at 07:08
  • It is working now as the resource layout file was not updated. –  Oct 03 '18 at 07:32

0 Answers0