Trouble with adding image source in android studio - android

I am trying to add a source image to an ImageView in Android Studio. I placed the image in the res/drawable folder. I have the same image placed in mdpi,hdpi,xhdpi,xxhdpi,and xxxhdpi.
However when I try to add the path to the image in xml it does not even show up. I have attached a screenshot of what I have.
Also I tried to clean and rebuild the project and still I cannot access the images in the drawable folder.
I should add that if I try and add the images to the mipmap folders. It works just fine and I can set the path of the images to mipmap.

You created the extra drawables folders inside of the main drawable folder instead of using the existing folders in the res/ directory. (See the mipmap folders?)
Also, don't need png extension in the XML, just the filename

In your XML remove file extension and replace . with _
android:src="#drawable/podcast_ac_new_2_9"

Related

why when put images on drawable v24 app crashes

When put images on drawable v24 app crashes , and use the same image
in drawable work correctly.
Look at which line your app is crashing in Logcat. You will be calling the resource file like this: R.drawable.yourresource. In this case it will work fine. If you change this line to R.drawableV24.yourresource and place the resource file in drawable V24 folder, it will work.
It all depends on how you identify the resource file :)
Please check your image drawable folder if the image in drawableV24 so transfer it in an only drawable folder and check it
Image resources placed in the res/drawable/ directory may be automatically optimized with lossless image compression by the aapt tool during the build process.
for more detail click here

Why I cannot access the image in my drawable folder in android studio?

Here is the screenshot of my code. I want to access the image in my drawable folder and pass it to a class. However, I have put in an image name as asif.JPG in a drawable folder but I cannot access it using R.drawable.asif.
Do clean build and it will regenerate R.java class.

Trouble in adding images to mipmap folder in android studio

I am trying to add images to mipmap folder by Batch Drawable Import but images automatically come under drawable folder as shown in screenshot. Can anyone tell me how to import images under mipmap folder?
Screenshot::
Open you file explorer and just move drawable files you want to move and paste into mipmap directory, and do not use any numerical number with image name.

adding images to drawable folder - showing blank image

while adding images to drawable folder using image asset i come accross this
How to solve this issue?
there is not any problem its the new window to add image asset android studio designed.
choose the image for asset type and give the path. then the android studio will generate different size of your image asset in different mipmap folders.
its a lot easier than before. if you dont want to use mipmap folders just copy and paste your file into youre desired folder in android studio manually.

Can't access images inside res/drawable in Android

I am new to Android development. To implement a photo gallery app, tutorial said to add images to res/drawable and access them via R.drawable.image1 .. etc. But there is no drawable folder default in eclipse, then I created a one and add images. But cannot access images, there is no option in R.drawable. as "image1"
Any idea ?
you should create "drawable" folder under "res", and you'd best place png image files in that folder. When accessing these image files programmingly.set an image for an ImageView for example:
Drawable imgDrawable=getResources().getDrawable(R.drawable.yourImageFileName));
imgView.setImageDrawable(imgDrawable);
Sometimes the drawable folder is not created by default Instead it will have "drawable-hdpi","drawable-mdpi" and "drawable-ldpi".These folders are for placing images for various screen densities to support different resolutions.Your "drawable folder" is for baseline medium density.
In your case create a folder named "drawable" under "res" and place your image inside that folder and you will be able to access it using R.id.imagename .Try refreshing the project and check whether you have created the drawable folder under the res folder.Also check the case of the folder name that you have created.
I faced same problem , but when i added those images again in jpg format it worked.
Might work for you too.
My System was based on windows 10 & was using android studio 4

Categories

Resources