示例#1
0
        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"];
        }
示例#2
0
        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);
        }