I have two overlapping imageviews. I want one to stay unchanged while the other one is completely transparent. I am drawing with canvas to the transparent one, but I can not get a transparent bitmap. How can I rectify this?
When I set its color closer to the transparent color (by diminishing alpha channel) using bitmap.eraseColor(color)
, it becomes closer and closer to black. When I set it to bm.eraseColor(Color.Transparent)
it appears completely black. The imageview that contains the bitmap has a transparent background, so I can show it from the outside of the black bitmap (which is supposed to transparent).
bm.add(decodeSampledBitmapFromResource(
getIntent().getExtras().getString("filePath"),
iv.getHeight(), iv.getWidth()).copy(
Bitmap.Config.ARGB_8888, true));
scaleBitmap();
originalImage.setImageBitmap(bm.get(N).copy(
Bitmap.Config.ARGB_8888, false));
bm.get(N).eraseColor(Color.TRANSPARENT);
iv.setImageBitmap(bm.get(N));
Here is the related part of the layout code:
<RelativeLayout
android:id="@+id/myImages"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="6"
>
<ImageView
android:id="@+id/originalImage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:scaleType="centerInside"
android:visibility="visible" />
<com.abacus.colorsketch.MyImageView
android:id="@+id/workingImage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/transparent"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:scaleType="centerInside" />
</RelativeLayout>