Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to load a drawable from the assets folder?

Can you load a drawable from a sub directory in the assets (not the drawable folder) folder?

like image 797
Jamie Avatar asked Feb 03 '11 10:02

Jamie


People also ask

How do I retrieve files from assets folder?

Right click on the assets folder, select New >> file (myText. txt) and your text. “Darkness cannot drive out darkness: only light can do that. Hate cannot drive out hate: only love can do that.”

How do I import a drawable file?

Drag and drop your images directly onto the Resource Manager window in Android Studio. Alternatively, you can click the plus icon (+), choose Import Drawables, as shown in figure 3, and then select the files and folders that you want to import. Figure 3: Select Import Drawables from the dropdown menu.

How do I use an assets folder?

Step 1: To create an asset folder in Android studio open your project in Android mode first as shown in the below image. Step 2: Go to the app > right-click > New > Folder > Asset Folder and create the asset folder. Step 3: Android Studio will open a dialog box. Keep all the settings default.

What is the use of assets folder in Android?

Assets provide a way to include arbitrary files like text, xml, fonts, music, and video in your application. If you try to include these files as "resources", Android will process them into its resource system and you will not be able to get the raw data.


1 Answers

Hope this help:

Drawable d = Drawable.createFromStream(getAssets().open("Cloths/btn_no.png"), null); 
like image 183
Rubycon Avatar answered Oct 12 '22 23:10

Rubycon