Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using JPEG as background on Android instead of PNG

I want to ask if Android accepts JPEG images instead of PNG, because PNG has bigger file size than JPEG.

I want to know how to use JPEG as background image in layout.xml file. Can you help me?

like image 360
user2884425 Avatar asked Nov 01 '13 17:11

user2884425


People also ask

Can I use JPEG in Android Studio?

Android Studio can convert PNG, JPG, BMP, or static GIF images to WebP format. You can convert individual images or folders of images.

Is it better to save as PNG or JPG?

Because of their different compression processes, JPEGs contain less data than PNGs — and therefore, are usually smaller in size. Unlike JPEGs, PNGs support transparent backgrounds, making them preferred for graphic design.

When should I use JPEG?

You should use a JPEG when…You want to print photos and/or artwork. At high resolution files with low compression, JPEGs are perfect for editing and then printing. You need to send a quick preview image to a client. JPEG images can be reduced to very small sizes making them great for emailing.


1 Answers

Just put a .jpg file in your res/drawable folder and refer to it as you normally would.

For example, if you put picture.jpg in your drawable folder, from one of your views you could just do the following.

<View
    android:id="@+id/view_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/picture" />
like image 197
Andrew Schuster Avatar answered Sep 22 '22 12:09

Andrew Schuster