I am an absolute beginner to Android. I am learning how to design a layout. But I am having problem with ImageView:
When I set the src
of ImageView with a PNG file, the dark color background is automatically added to all the images like in screenshot:
The real image of is like this: (There's no background)
This is the xml layout for my toolbar and I did not set any background for the ImageView:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:background="?attr/colorPrimaryDark">
<ImageButton
android:id="@+id/btn_open_sidebar"
android:src="@drawable/open_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageButton
android:layout_alignParentRight="true"
android:id="@+id/btn_calendar"
android:src="@drawable/calendar"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
So how can I make that PNG image transparent or with the same background as the toolbar? I mean, how to remove that default dark background color?
I think because you are using ImageButton
android adds a default background to it.
you can add android:backgroud="@android:color/transparent"
to your ImageButton
s and force android to use transparent background.