2013-12-13 58 views
-1

我有图像视图里面的框架布局,我把运动时在图像视图上的随机贴纸,但是当我保存图像位图使用框架布局图 - 抓住然后图像保存但有不必要的黑色部分进来保存的图像。 Actual imageImageview图像捕捉不按需要来

After save with sticker

Required

我想点阵图没有这个黑part.Please help.Here是我的布局和代码。

<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> 

这是我用来创建位图的代码。

FrameLayout fl=(FrameLayout) findViewById(R.id.fl_effect_view); 
f1.setDrawingCacheEnabled(true); 
Bitmap b=Bitmap.createBitmap(f1.getDrawingCache()); 
f1.setDrawingCacheEnabled(false); 

回答

2

尝试设置视图的大小,你得到绘图缓存之前:

ImageView bottomImage = (ImageView) findViewById(R.id.im_gselected_image); 
f1.layout(0, 0, bottomImage.getMeasuredWidth(), bottomImage.getMeasuredHeight()); 
Bitmap b=Bitmap.createBitmap(f1.getDrawingCache(true)); 

这将迫使你的结果有一个特定的大小和位置,并将裁剪的一切,是出你定义的边界。

请让我现在,如果这为你工作。