views:

751

answers:

2
<ImageButton android:id="@+id/previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/media_skip_backward"
android:background="@drawable/transparent"></ImageButton>

This is what I tried to get a transparent ImageButton so as to place those buttons on a SurfaceView. But Eclipse, gives me an error in the project as soon as I include the transparent line in xml.

Please help.

+5  A: 

Try using null for the background ...

android:background="@null"
Quintin Robinson
Thank you.This works. Only the image is seen and not the box around it. But can I lay this button over the SurfacaView ie over the video preview? Is this possible? How do I do it?
Namratha
@Namratha The `SurfaceView` should allow you to blace your buttons over a surface but note: "This can be used to place overlays such as buttons on top of the Surface, though note however that it can have an impact on performance since a full alpha-blended composite will be performed each time the Surface changes." from http://developer.android.com/reference/android/view/SurfaceView.html
Quintin Robinson
A: 

Remove this line :

android:background="@drawable/transparent">

And in your activity class set

ImageButton btn = (ImageButton)findViewById(R.id.previous);
btn.setAlpha(100);

You can set alpha level 0 to 255

o means transparent and 255 means opaque.

Nishant Shah
But does this enable the button to lie on top of the SurfaceView?
Namratha
Most probably it should work. Just check it out.
Nishant Shah