mafioso
mafioso

Reputation: 1632

Add image to drawable folder with relative path in android

I want to add some images to the drawable folder in Android Studio.
My problem is that I don't know how to add them from a relative path.
And is it the right way to add an ImageAsset or is there an other solution?
In my project, I have a pics folder and I want to add the pictures from this folder to the drawable folder. It looks like that:

enter image description here

And how can I invoke these images in the code?

 <Button
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="0.5"
        android:id="@+id/btnRecordVideo"
        />

android:background and how would the path look like?

Upvotes: 0

Views: 603

Answers (2)

Suman Astani
Suman Astani

Reputation: 1191

Copy the images and right click on android studio ide and paste inside drawable folder:

call it in xml as img:src: @drawable/filename.jpg Hope it helps

Upvotes: 0

rhari
rhari

Reputation: 1367

Copy all the pictures to the app\src\main\res\drawable directory (create the folder if it does not exist). To refer to them in xml, use @drawable/file_name.

Upvotes: 1

Related Questions