具有特定宽度和高度的帧布局位图

Framelayout bitmap with specific width and height

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

检查以下代码

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();
    }