I want to know how I can add a background image in an android studio application, I have read that it should be in the drawable folder; but I do not know how to add the image to that folder. The image is downloaded from the internet.
I want to know how I can add a background image in an android studio application, I have read that it should be in the drawable folder; but I do not know how to add the image to that folder. The image is downloaded from the internet.
Ctrl + c to the image you want after Ctrl + v in the resources> drawable folder. Then in the layout of the activity you click, in the properties you go to the background and look for the image (there are different types of background, one to put another image to put only one color ...) and go!
Another option is to go to the drawable folder from the browser and paste the image in the drawable folder, then you can use it in any View as imageView, button, etc. (in the background property for example)
You can use any image that you have inside your folder /drawable
or /mipmap
you can copy them in the folder you want:
In your layout you define the background as the background with the property:
android:background
for example assuming an image called android.jpg
, if you have it stored in the / drawable directory, use:
android:background="@drawable/ic_launcher"
if it is inside the / mipmap directory, use:
android:background="@mipmap/ic_launcher"
for example:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/android"
android:padding="10dp"/>
and in this way you will have your background image: