0

I have a video-call sdk which takes a Xamarin.Forms.AbsoluteLayout instance while initializing, so that it can place the video in that container.

I have separate UI for android and iOS. In android I have a layout file (.axml) inside which there is an AbsoluteLayout. I am accessing the AbsoluteLayout programmatically. But I am getting compilation error on the second line of the code below,

[error: cannot convert type Android.View.View to Xamarin.Forms.AbsoluteLayout]

_view = activity.LayoutInflater.Inflate(Resource.Layout.Video, this, false);
var container = (Xamarin.Forms.AbsoluteLayout)_view.FindViewById(Resource.Id.container);

Although if I replace the typecast with (Android.Widget.AbsoluteLayout) no compilation error occurs.

Koushik Sarkar
  • 480
  • 2
  • 6
  • 18
  • I don't think it is possible, why do you want to do this? – Grace Feng Jun 29 '17 at 01:39
  • The sdk I am using is built to use xaml based page. But we have separate UIs for iOS and Android. If we had a xaml page it would be easy to send Xamarin.Forms.AbsoluteLayout to the sdk as a container. But in our case we have an Android.Widget.AbsoluteLayout. :( – Koushik Sarkar Jun 29 '17 at 04:18
  • Are you trying to render the `Xamarin.Forms.AbsoluteLayout` in PCL to your custom layout (`Android.Widget.AbsoluteLayout`) in android platform? – Grace Feng Jun 29 '17 at 06:21
  • No we don't have any xaml page so there is no `Xamarin.Forms.AbsoluteLayout` in PCL. The code snippet is in a `VideoCallPageRenderer : PageRenderer ` . It takes a layout file, inflates it and tries to get the AbsoluteLayout inside the layout file using `view.FindViewById(Resource.Id.container)`. `FindViewById` is returning `Android.Widget.AbsoluteLayout`. Which needs to be converted to `(Xamarin.Forms.AbsoluteLayout`. Because the video call sdk takes a `Xamarin.Forms.AbsoluteLayout` as a parameter. – Koushik Sarkar Jun 29 '17 at 06:46

1 Answers1

0

android's AbsoluteLayout is in Android.Widget package, so change it:

var container = (Android.Widget.AbsoluteLayout)_view.FindViewById(Resource.Id.container);
Rafal Malek
  • 3,493
  • 1
  • 17
  • 18