Forum Xamarin.Forms

Custom Renderer: Read view from layout

MaruMaru DEMember ✭✭


I have an Android example I want to put into Xamarin.Forms:

  android:layout_height="fill_parent" />

NativeAndroidView widget = (NativeAndroidView) findViewById(;

The problem is that I can't create an object from that NativeAndroidViewinside of my custom renderer and pass it to SetNativeView(), the API from the NativeAndroidViewisn't supporting this. So I was wondering how I can put this together in Forms.


Best Answer


  • AdamMeaneyAdamMeaney USMember ✭✭✭✭✭

    You need to create the view in the usual Android way in the renderer.

    So instead of finding it by id, you should use

    NativeAndroidView control = (NativeAndroidView)LayoutInflater.From(Forms.Context).Inflate(Resource.Layout.filename, null, false);
  • MaruMaru DEMember ✭✭

    @AdamMeaney Thanks for the hint!
    Is filename in Resource.Layout.filename a native Android layout? Can you maybe make a short/simple example?

Sign In or Register to comment.