why surf the web ? swim it !!!


Hello there everyone,

This week we are going to see how to import images directly to the DRAWABLE folder in the Android Project

Step 1: Rename the image with only small cases and underscore (_) only

Step 2: The image can be in any format such as .jpg/.png

Step 3: Now, you can programmatically add them as given below

In XML:

app:srcCompat="@drawable/sample_image" // no need to mention extension

In JAVA:

testButton.setImageDrawable(getResources().getDrawable(R.drawable.sample_image));

NOTE:

THERE ARE SIMPLE WAY TO DO MANY THINGS IN ANDROID

WE JUST DON’T SEARCH / TRY HARDER

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Why Surf Swim

Subscribe now to keep reading and get access to the full archive.

Continue reading