Imageview绘图捕获不是根据需要 [英] Imageview Drawing catch not come as needed
问题描述
我在框架布局中有图像视图,我在运行时在图像视图上放置了随机贴纸,但是当我使用框架布局绘图保存图像位图时,图像保存但是带有不必要的黑色部分会出现在保存的图像中。
http://i.stack.imgur.com/vWwfl.jpg [ ^ ]
http://i.stack.imgur.com/OIhdp.jpg [ ^ ]
http://i.stack.imgur.com/zJVK2.jpg [ ^ ]
i想要没有这个黑色部分的位图。请帮助。这是我的布局和代码。
I have image view inside frame layout ,i put random sticker on image view at run time but when i save image bitmap using frame layout drawing-catch then image save but with unnecessary black part comes in saved image.
http://i.stack.imgur.com/vWwfl.jpg[^]
http://i.stack.imgur.com/OIhdp.jpg[^]
http://i.stack.imgur.com/zJVK2.jpg[^]
i want bitmap without this black part.Please help.Here is my layout and code.
<FrameLayout
android:id="@+id/fl_effect_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/rl_title"
android:layout_marginBottom="83dp" >
<ImageView
android:id="@+id/im_gselected_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
>
</ImageView>
</FrameLayout>
这是我用来创建位图的代码。
Here is code that i use to create bitmap.
FrameLayout fl=(FrameLayout) findViewById(R.id.fl_effect_view);
f1.setDrawingCacheEnabled(true);
Bitmap b=Bitmap.createBitmap(f1.getDrawingCache());
f1.setDrawingCacheEnabled(false);
推荐答案
使用ImageView,而不是FrameLayout
use ImageView, not FrameLayout
ImageView fl=(ImageView) findViewById(R.id.im_gselected_image);
f1.setDrawingCacheEnabled(true);
Bitmap b=Bitmap.createBitmap(f1.getDrawingCache());
f1.setDrawingCacheEnabled(false);
这篇关于Imageview绘图捕获不是根据需要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!