Get bitmap from layout

前端 未结 3 1413
青春惊慌失措
青春惊慌失措 2020-12-05 11:57

I\'m trying to inflate a layout and use that to set a bitmap on an image view. Then, I\'m adding that imageview to a linear layout and displaying the linear layout. Here\'s

3条回答
  •  执念已碎
    2020-12-05 12:41

        /***
     * 
     * @param flameLayout/linearLayout...
     * @param width
     * @param height
     * @return
     */
    public static Bitmap viewToBitmap(View view, int width, int height) {
        Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
        Canvas canvas = new Canvas(bitmap);
        view.draw(canvas);
        return bitmap;
    }
    

提交回复
热议问题