Add Resources Set Background Android Studio

Add Resources Set Background Android Studio

android, TUTORIALS

Add Resources Set Background Android Studio




In this lesson Add Resources Set Background Android Studio we are gonna show how to add resources to our project like images and audio files to our application. In the updated version of android studio we can do it many ways. Here we show some important ways we often used.
Step 1: Create a new project – Add Resources Set Background Android Studio
As a first step we have to create a new project from the file menu. And then it automatically creates the required files and folders for the project.
In this folder structure we can find the folder named res at location app -> src -> main -> res -> midmap-hdpi. This is the folder where we have to place our images at .png extension which is most preferable extension. At this location we can just drag and drop the image files where ever from your computer.
Add Resources Set Background Android Studio
Or you can go to your exact project folder using the file explorer and paste the image files there. In Add Resources Set Background Android Studio and come back to Android studio refresh the project by doing the refresh button after the menu bar location.
Add Resources Set Background Android Studio
After click this refresh button then android studio will reload all the files from the disk to the project disk. But in the advanced version of android studio we don’t need to refresh the project. It automatically refresh itself and shows the file at the project folder. You can experience this by doing it yourself.
Step 2: Add a Sound File – Add Resources Set Background Android Studio
After knowing how to add a image in to our project now its time add the sound files like wav or mp3 files into our project.
To add a sound file we have to create a new folder called raw inside the res folder. Because the Android applications as default access the audio files from this project.
And after create this folder we can drag and drop or just copy and paste into that folder like we did for the above adding image resource to the project.

Another one method to load the image or sound files is using the JSON which means fetch the content from the other website or database in different locations using the technology called JSON.

Setting Background to the Layout
The another topic in this tutorial we have to learn about is setting the background image to the application screen.
Here we use the background image from the drawable folder using the image we already copy and paste at the drawable folder.
And now find the background attribute from the right side properties sidebar. And click the settings icon, it pop up the options wizard to choose among the various options like color and images.
From here choose the image what we will upload to set as a background.
Add Resources Set Background Android Studio
Now the image is set as the background for our application. We can check this by run the application and see the result.
Add Resources Set Background Android Studio
And the result will be like this,
Add Resources Set Background Android Studio
And that’s it, here we done the two works as one shot. As first we add the resources to our project and then we use them for our project.
We hope this lesson will gives some knowledge on how to Add Resources Set Background Android Studio. We will learn a lot more about android in the upcoming lessons.

Leave a Reply