private void InitImageIcon() { if (!_hasIcon) { return; } ImageView icon = new ImageView(Context); var lParams = new LayoutParams((int)Resources.GetDimension(Resource.Dimension.chip_height), (int)Resources.GetDimension(Resource.Dimension.chip_height)); lParams.AddRule(Build.VERSION.SdkInt >= BuildVersionCodes.JellyBeanMr1 ? LayoutRules.AlignParentStart : LayoutRules.AlignParentLeft); icon.LayoutParameters = lParams; icon.SetScaleType(ImageView.ScaleType.FitCenter); icon.Id = ChipUtils.IMAGE_ID; if (_chipIcon != null) { if (_chipIcon is BitmapDrawable bitmapDrawable && bitmapDrawable.Bitmap != null) { Bitmap bitmap = ((BitmapDrawable)_chipIcon).Bitmap; bitmap = ChipUtils.GetSquareBitmap(bitmap); bitmap = ChipUtils.GetScaledBitmap(Context, bitmap); icon.SetImageBitmap(ChipUtils.GetCircleBitmap(Context, bitmap)); } else { icon.SetImageDrawable(_chipIcon); } }
private void InitCloseImage() { if (!_closable) { return; } var lParams = new LayoutParams((int)Resources.GetDimension(Resource.Dimension.chip_close_icon_size_medium), (int)Resources.GetDimension(Resource.Dimension.chip_close_icon_size_medium)); lParams.AddRule(Build.VERSION.SdkInt >= BuildVersionCodes.JellyBean ? LayoutRules.EndOf : LayoutRules.RightOf, ChipUtils.TEXT_ID); lParams.AddRule(LayoutRules.CenterVertical); lParams.SetMargins((int)Resources.GetDimension(Resource.Dimension.chip_close_horizontal_margin), 0, (int)Resources.GetDimension(Resource.Dimension.chip_close_horizontal_margin), 0); closeImageView.LayoutParameters = lParams; closeImageView.SetScaleType(ImageView.ScaleType.Center); closeImageView.SetImageDrawable(_closeIcon); ChipUtils.SetIconColor(closeImageView, _closeColor); InitCloseClick(); AddView(closeImageView); }