public CameraScannerMaskView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); cameraLensView = new CameraLensView(context); cameraLensView.init(context, attrs, defStyleAttr); scannerBarView = new ScannerBarView(context); scannerBarView.init(context, attrs, defStyleAttr); addView(cameraLensView, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); addView(scannerBarView, new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); }