Currently I am trying to implement a custom renderer for android, which is supposed to display a pdf document.
For doing that I need to add some android controls from within the custom renderer and add them to the current view.
The issue is: The code runs through fine, but I still end up looking at a blank page.
Maybe someone can give me a hint on what I might be missing out so far?
Thanks a lot in advance!
Btw, here's my code so far:
`
protected override void OnElementChanged(ElementChangedEventArgs e)
{
base.OnElementChanged(e);
if (e.NewElement == null)
return;
if (e.NewElement.BindingContext != null)
model = e.NewElement.BindingContext as MediaViewModel;
this.RemoveAllViews();
try
{
OpenRenderer(this.Context, model);
}
catch (IOException ex)
{
ex.PrintStackTrace();
Toast.MakeText(this.Context, "Error! " + ex.Message, ToastLength.Short).Show();
}
Droid.Widget.ScrollView scroller = new Droid.Widget.ScrollView(this.Context)
{
HorizontalScrollBarEnabled = false,
LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent)
};
this.AddView(scroller);
pdfLayout = new LinearLayout(this.Context)
{
Orientation = Droid.Widget.Orientation.Vertical,
LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent)
};
scroller.AddView(pdfLayout);
Droid.Widget.ImageView imageview = new Droid.Widget.ImageView(this.Context)
{
LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent)
};
ShowPage(0, imageview);
pdfLayout.AddView(imageview);
if (mPdfRenderer.PageCount > 1)
{
Droid.Widget.ImageView imageview2 = new Droid.Widget.ImageView(this.Context)
{
LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.WrapContent)
};
ShowPage(1, imageview2);
pdfLayout.AddView(imageview2);
lastPageAdded++;
}
this.Invalidate();
this.RequestLayout();
}
`