当前位置: 代码迷 >> Android >> Android ViewToBit地图
  详细解决方案

Android ViewToBit地图

热度:99   发布时间:2016-04-28 03:11:44.0
Android ViewToBitmap
 /**         * 把View绘制到Bitmap上         * @param view 需要绘制的View         * @param width 该View的宽度         * @param height 该View的高度         * @return 返回Bitmap对象         */        public static Bitmap getBitmapFromView(View view,int width,int height) {                int widthSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY);                int heightSpec = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY);                view.measure(widthSpec, heightSpec);                view.layout(0, 0, width, height);                Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);                Canvas canvas = new Canvas(bitmap);                view.draw(canvas);                return bitmap;        }

  相关解决方案