I have a view where I display the preview of the camera (previewView).
I added a button (button_load) to choose a picture on the phone and I would like that once this picture is chosen, it is displayed in transparency over the preview of the camera (in PhotoPreChargee).
Except that I can not display a view over the preview of the camera.
My code :
OnCLick (button_load) :
private void loadImage(){
Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI);
intent.setType("image/*");
intent.putExtra("return-data", true);
startActivityForResult(intent, 100);
}
When the picture is chosen :
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode==100 && resultCode==RESULT_OK) {
Uri uri = data.getData();
photoPreChargee.setImageURI(uri); // set URI
photoPreChargee.setVisibility(View.VISIBLE); // set Visible
photoPreChargee.setAlpha(0.5F); // transparency
previewView.setVisibility(View.VISIBLE); // already Visible
}
}
The problem is that the photoPreChargee view is always invisible. It doesn't overlay the previewView in transparency.
Here is the layout of my views:
Do you have any idea why? How to do it?
Thx for your help :)
SOLUTION (by snachmsm):
In onCreate()
previewView = findViewById(R.id.previewView);
previewView.setImplementationMode(PreviewView.ImplementationMode.COMPATIBLE);
and now I can display a View over the previewView
