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 will be the image we are tinting. Then we have the _log
and tag
properties...