O'Reilly logo

Xamarin Blueprints by Michael Williams

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Building the CustomImageRenderer for Android

Add a new folder into the Renderers folder called CusotmImage, add a new file called CustomImageRenderer.cs, and implement the following:

public class CustomImageRenderer : ViewRenderer<CustomImage, ImageView>  
    { 
        #region Private Properties 
 
        private readonly string _tag; 
 
        private ImageView _imageView; 
 
        private CustomImage _customImage; 
 
        private ILogger _log; 
 
        private Bitmap _bitmap; 
 
        #endregion 
 
        #region Constructors 
 
        public CustomImageRenderer() 
        { 
            _log = IoC.Resolve<ILogger> (); 
            _tag = string.Format ("{0} ", GetType ()); 
        } 
 
        #endregion 

We are going to use an ImageView as the native control. We also have a local CustomImage, which will reference the element we are rendering on. We also have a local Bitmap, which ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required