If I understood your question, then this is what you wanted: You tried to impose a transparent view on your activity and cut holes to see a few things.
here I found a useful example that shows how you can cut bitmap images and combine them. I would suggest that for your problem, just take part in cutting the bitmap and don't forget to set the backview to the image with opacity, as shown here.
android: background = "# 00ffffff"
here is the layout i created
<ImageButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@android:color/transparent" android:src="@drawable/ic_launcher" android:layout_alignParentRight="true" android:layout_alignParentBottom="true"/>" <ImageView android:id="@+id/img" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#00ffffff" android:scaleType="centerCrop" > </ImageView> </RelativeLayout>
and this is my maneuverability
public class MainActivity extends the action {
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ImageView iv = (ImageView) findViewById(R.id.img); Bitmap foreground = BitmapFactory.decodeResource(getResources(), R.drawable.android_cat_wanted); foreground = punchAHoleInABitmap(foreground); iv.setImageBitmap(foreground); } private Bitmap punchAHoleInABitmap(Bitmap foreground) { Bitmap bitmap = Bitmap.createBitmap(foreground.getWidth(), foreground.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(bitmap); Paint paint = new Paint(); canvas.drawBitmap(foreground, 0, 0, paint); paint.setAntiAlias(true); paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR)); float radius = (float)(getScreenSize().x *.35); float x = (float) ((getScreenSize().x*.5)); float y = (float) ((getScreenSize().y*.5)); canvas.drawCircle(x, y, radius, paint); return bitmap; } @SuppressLint("NewApi") private Point getScreenSize() { WindowManager window = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Display display = window.getDefaultDisplay(); Point size = new Point(); display.getSize(size); return size; }
}
hope you find it useful
source share