public override void SetImageBitmap(Bitmap bm) { RoundedBitmapDrawable roundedDrawable = RoundedBitmapDrawableFactory.Create(Resources, bm); roundedDrawable.Circular = true; base.SetImageDrawable(roundedDrawable); }
private void InitData() { Bitmap avatar = BitmapFactory.DecodeResource(Resources, Resource.Drawable.avacar); RoundedBitmapDrawable roundDrawable = RoundedBitmapDrawableFactory.Create(Resources, avatar); roundDrawable.Circular = true; roundDrawable.SetAntiAlias(true); userAvatar.SetImageDrawable(roundDrawable); if (userData == null) { return; } userName.Text = $"{userData["FirstName"]} {userData["MiddleName"]} {userData["LastName"]}"; genderGroup.Check(Resource.Id.userprofile_gender_male); userBirthDate.Text = ((DateTime)userData["BirthDate"]).ToShortDateString(); choosenBirthDate = (DateTime)userData["BirthDate"]; }
private Drawable GetRoundedBitmap(int imageId) { Bitmap src = BitmapFactory.DecodeResource(this.Resources, imageId); Bitmap dst; if (src.Width >= src.Height) { dst = Bitmap.CreateBitmap(src, src.Width / 2 - src.Height / 2, 0, src.Height, src.Height); } else { dst = Bitmap.CreateBitmap(src, 0, src.Height / 2 - src.Width / 2, src.Width, src.Width); } RoundedBitmapDrawable roundedBitmapDrawable = RoundedBitmapDrawableFactory.Create(this.Resources, dst); roundedBitmapDrawable.CornerRadius = (dst.Width / 2); roundedBitmapDrawable.SetAntiAlias(true); return(roundedBitmapDrawable); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { StudentInfoView = inflater.Inflate(Resource.Layout.StudentInfoFragmentLayout, container, false); StudentInfoView.FindViewById <Button>(Resource.Id.BoxCombinationInstructions) .Click += ShowBoxInstructions; StudentInfoView.FindViewById <Button>(Resource.Id.StudentChecksheet) .SetCommand("Click", ViewModel.ShowChecksheetCommand); StudentInfoView.FindViewById <Button>(Resource.Id.MessagingAndTelephoneInstructions) .Click += ShowTelephoneInstructions; ImageView _accountPhotoView = StudentInfoView.FindViewById <ImageView>(Resource.Id.AccountPhoto); RoundedBitmapDrawable _drawable = null; switch (userIdNumber) { case "130000": { _drawable = RoundedBitmapDrawableFactory.Create( Resources, BitmapFactory.DecodeResource( Resources, Resource.Drawable.abby)); } break; case "124801": { _drawable = RoundedBitmapDrawableFactory.Create( Resources, BitmapFactory.DecodeResource( Resources, Resource.Drawable.becki)); } break; case "118965": { _drawable = RoundedBitmapDrawableFactory.Create( Resources, BitmapFactory.DecodeResource( Resources, Resource.Drawable.account_photo)); } break; case "123456": { _drawable = RoundedBitmapDrawableFactory.Create( Resources, BitmapFactory.DecodeResource( Resources, Resource.Drawable.nick)); } break; } _drawable.CornerRadius = Math.Min(_drawable.MinimumWidth, _drawable.MinimumHeight); Activity.RunOnUiThread(() => { _accountPhotoView.SetImageDrawable(_drawable); }); //Resources _resources = Resources; //Bitmap _accountPhotoBitmap = BitmapFactory.DecodeResource(Resources, Resource.Drawable.account_photo); ///*SEPARATE THREAD*/ ImageView _accountPhotoView = StudentInfoView.FindViewById<ImageView>(Resource.Id.AccountPhoto); //RoundedBitmapDrawable _drawable = RoundedBitmapDrawableFactory.Create(Resources, // BitmapFactory.DecodeResource(Resources, Resource.Drawable.account_photo)); //_drawable.CornerRadius = System.Math.Min(_drawable.MinimumWidth, _drawable.MinimumHeight); #region NOTE // Use the following only if image has same width and height: // Replace _drawable.CorderRadius = ... with // _drawable.Circular = true; #endregion ParentFragment.View.FindViewById <TabLayout>( Resource.Id.MainTabLayout).TabReselected += TabReselected; SetStudentInfo(); /* Use this to return your custom view for this Fragment */ return(StudentInfoView); }