0

I have a FrameLayout containing a CameraPreview and a RelativeLayout. The RelativeLayout contains some ImageButtons. Thus:

<FrameLayout>
  <CameraPreview/>
  <RelativeLayout>
    <ImageButton/>
    <ImageButton/>
  </RelativeLayout>
</FrameLayout>

I'm using the CameraPreview to live-preview the image coming from the camera. This works correctly. The ImageButtons display drawable bitmaps, and appear over the camera preview.

The problem is that the buttons are semi-transparent: the camera image is visible in their background. I want them to be fully-opaque to make them more visible. How do I do this?

I've tried calling SetAlpha() on the buttons but this doesn't appear to have any effect.

Can anyone suggest how I can make the buttons opaque?

2
  • The buttons by default wouldn't be transparent. I'm guessing the onDraw call on your cameraPreview is intermittently drawing on top of your buttons giving it the effect of transparency. Maybe try setting the android:bringToFront property on the buttons?
    – Andrew G
    Aug 13, 2013 at 20:14
  • @AndrewG Thanks for the suggestion! Unfortunately it didn't make any difference. The buttons are already at the top of the Z-order due to their position in the layout. I suspect you're right about the overdrawing, but I still haven't found a way to fix it. Aug 14, 2013 at 15:55

1 Answer 1

0

The problem turned-out to be that the image buttons had no background drawable resource and weren't inheriting one from any of the views in their parent hierarchy.

Adding android:background="@android:drawable/btn_default" to the ImageButton's xml definition solved the problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.