A very standard overlay tutorial in this link was followed for developing the camera preview with overlay. However, when I change the <Button/>
to <ImageView/>
or <ImageButton/>
the image doesn't get displayed. All I am getting is camera preview while using <ImageView/>
and on using <ImageButton/>
the images are not shown however little white lines at places where there should be images are displayed. The images are present in mipmap-xxhdpi
. These buttons will be used to start another activity or take picture on click by user.
I've looked into questions on StackOverFlow but answer here doesn't work for me.
Other Relevant Details
The minSdkVersion is 16 and compileSdkVersion is 25. When I run the app in emulator on API-21 or above all I am getting is a black screen.
Q1: How to overlay <ImageView/>
or <ImageButton/>
on camera preview?
Q2: Would getting black screen have something to do with Camera API (old) being deprecated and I have to build separate classes to take into account different API?
Like the code below
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
//do something
} else {
//do something else
}