Toygirl
Toygirl

Reputation: 79

How to build a transparent ImageButton in Android?

I want to build a transparent ImageButton, I put these buttons in a SurfaceView. But when I put the code in XML, Eclipse returns an error. I don't know how to solve, any help will be appreciated.

<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>

Upvotes: 1

Views: 221

Answers (5)

NAP-Developer
NAP-Developer

Reputation: 3796

You just try this types of code in your xml file

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

Upvotes: 0

Winnie
Winnie

Reputation: 769

you can try this :

 android:background="@android:color/transparent"

Upvotes: 1

Jignesh Ansodariya
Jignesh Ansodariya

Reputation: 12695

you can use this

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

Upvotes: 2

Hesam
Hesam

Reputation: 53600

My suggestion is in res/values create colors.xml file and add transparent color code in it. something like

<resources>
    <color name="transparent">#00000000</color>
    <color name="Black">#000000</color>
    <color name="Trans_Black">#80000000</color>
    <color name="Trans_Black_Darker">#BB000000</color>    
</resources>

Now change your path to android:background="@color/transparent"

Upvotes: 0

Neal
Neal

Reputation: 379

Try using

android:background="@null"

Upvotes: 0

Related Questions