I have a drawing application and I have methods for saving pictures drawn. But I only get a black bitmap picture with the save button. Where is the problem ?
My problem, was resolved, but I have one small detail. My application get down, when I change my xml. to this.
我的问题解决了,但我有一个小细节。当我更改xml时,我的应用程序就会崩溃。这个。
4 个解决方案
#1
2
Actually You are passing the view (v) of your Button btn6 in method save(v)- Pass linear layout object which is mcontent or mView, then that would be save(mContent), This will solve your problem
Before it you should call View.setDrawingCache(true);
在它之前,您应该调用View.setDrawingCache(true);
#4
0
I've created a cutom component that extends GroupView and used this method to save this layout to a bitmap.
我创建了一个cutom组件,它扩展了GroupView并使用此方法将这个布局保存到位图中。
public Bitmap createBitmap() {
//Log.d("Pin", "Image W ["+this.getWidth()+"] x H ["+this.getHeight()+"]");
Bitmap b = Bitmap.createBitmap(this.getWidth(), this.getHeight(), Bitmap.Config.RGB_565);
Canvas c = new Canvas(b);
this.draw(c);
return b;
}
Hope it helps you. If you want to save your layout you should change this with the entire layout you want to save