具有特定宽度和高度的Framelayout位图

时间:2016-06-11 09:33:10

标签: android bitmap android-bitmap android-framelayout

如何在将framelayout保存到图像时使用特定的位图宽度和高度?

1 个答案:

答案 0 :(得分:0)

检查以下代码

public Bitmap convertFrameToBitmap(View view) {
    Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    view.draw(canvas);
    return bitmap;
}


ry {
        FileOutputStream output = new FileOutputStream(getActivity().getFilesDir() + File.separator+ image.png");
        bitmap.compress(Bitmap.CompressFormat.PNG, 100, output);
        output.close();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }