Reputation: 3585
I'm placing an ImageButton
on top of a MapView
. The ImageButton
is a save icon with a transparent background. It looks great on my Windows Phone 7 app but on my Android app the background is not really transparent. As you can see the transparent background looks like a big square Button
.
How can I truly make the background transparent? Picture and xml pasted below. Thanks, Gary
<?xml version="1.0" encoding="utf-8"?>
<TextView
android:id="@+id/tvMAP"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Map"
style="@style/bigtype" />
<com.google.android.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="mykeyhere"
android:clickable="true" />
<ImageButton
android:id="@+id/ImageButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/save_white" />
</RelativeLayout>
Upvotes: 2
Views: 999
Reputation: 3111
The trick here is to make the background transparent. By default the background is of gray color.
The code should be like this,
<ImageButton
android:id="@+id/ImageButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/save_white"
android:background="@android:color/transparent" />
Upvotes: 2
Reputation: 6849
don't use android:src
but use background instead
<ImageButton
android:id="@+id/ImageButton01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/save_white" />
Upvotes: 1