2013-12-13 109 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)); 

這將迫使你的結果有一個特定的大小和位置,並將裁剪的一切,是出你定義的邊界。

請讓我現在,如果這爲你工作。