Is there is any drawback of using png
as a background for a Button
or EditText
. Or should I write a code for XML
for background of Button or EditText. I want to know which is the better way.
Asked
Active
Viewed 1,296 times
0

Phantômaxx
- 37,901
- 21
- 84
- 115

Deependra Dhakal
- 59
- 1
- 9
-
Avoid PNG or JPG images as backgrounds, untill you can accomplish UI design using Shape Drawables. – Chintan Soni Jan 30 '18 at 13:44
4 Answers
0
You can use color,drawable file or image as background
Color
android:background="#2F6699"
Drawable
android:background="@drawable/edittext_background"
Image
android:background="@drawable/ic_launcher"
Drawable file
<?xml version="1.0" encoding="utf-8" ?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:thickness="0dp"
android:shape="rectangle">
<stroke android:width="2dp"
android:color="#2F6699"/>
<corners android:radius="3dp" />
<gradient android:startColor="#C8C8C8"
android:endColor="#FFFFFF"
android:type="linear"
android:angle="270"/>
</shape>

user311086
- 920
- 2
- 16
- 29
0
I think you can try 9 patch image for button and edittext background.
9 Patch:
9-Patch images are stretchable, repeatable images reduced to their smallest size; users draw a right and bottom, solid black 1 pixel border to tell the system how to place the content within the image.
For more information visit this post:

Mitesh Vanaliya
- 2,491
- 24
- 39
0
just put png image into drawable, and than set it in xml via android:background="@drawable/image.png"

Samuel Senigl
- 31
- 2
0
Use it in button properties
android:background="@drawable/imageName"