I designed a button in photoshop cs6 and save it as a png image. When try to add it in android studio as an imageView or imageButton it includes the background color. I tried android:backgroud="@android:color/transparent"
but no luck.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="@+id/screenTextView"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_weight="1"
android:background="#BDBDBD"
android:ems="10"
android:fadingEdge="none"
android:hint="0"
android:inputType="none"
android:textAlignment="viewEnd"
android:textSize="30sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageButton
android:id="@+id/imageButton"
android:layout_width="0dp"
android:layout_height="160dp"
android:layout_weight="1"
android:background="@android:color/transparent"
app:srcCompat="@drawable/buttonn1" />
</LinearLayout>
EDIT : https://github.com/Gamer1989/project/issues/1 You can see the images from here.
3
Answers
This works for me. If it dont works for u you should consider that there is a issue with ur png. Are u using a importer to add images to ur project? For example Batch Drawable Importer.
It means the png file does not have a transparent background. Be sure the referred file does have this feature.
This link teaches how to do it.
You can open your designed photoshop file into Adobe XD and then select your shapes/button that you wants to export, export those in png format, after that you can copy them into android studio drawable folder and you can use it. No background colour will be included like before.
PNG shapes exported from Photoshop:
Same shapes exported from Adobe XD: