示例#1
0
        /**
         * Creates an icon with the current content and style.
         * <p/>
         * This method is useful if a custom view has previously been set, or if text content is not
         * applicable.
         */

        public Bitmap MakeIcon()
        {
            int measureSpec = View.MeasureSpec.MakeMeasureSpec(0, MeasureSpecMode.Unspecified);

            mContainer.Measure(measureSpec, measureSpec);

            int measuredWidth  = mContainer.MeasuredWidth;
            int measuredHeight = mContainer.MeasuredHeight;

            mContainer.Layout(0, 0, measuredWidth, measuredHeight);

            Bitmap r = Bitmap.CreateBitmap(measuredWidth, measuredHeight, Bitmap.Config.Argb8888);

            r.EraseColor(Color.Transparent);

            Canvas canvas = new Canvas(r);

            canvas.DrawColor(Color.White, PorterDuff.Mode.SrcIn);
            Drawable drawable = mContainer.Background;

            if (drawable != null)
            {
                drawable.Draw(canvas);
            }
            mContainer.Draw(canvas);
            return(r);
        }