Cant reference a Folder as Source for ImageView - android

basically i have created a folder insde the Drawable Folder called "logo" with a image at different scales, i have seen in different tutorials that you can just reference the folder in the atributte "src" and thats it, you can totally use the view normally, but for some reason i cant do that in here.
i have tried changing the name of the folder but i still have the same problem, plus if i just drop the images inside the drawable folder, i can use them normally...
Thanks for your help !
enter image description here

Related

Android Studio: Is is possible to set default drawable folder?

I am having a rather annoying scenario where I work with a lot of drawable shapes, many of which are slightly changed variants of others. The annoying thing is, when I paste the drawable, it automatically defaults to a random resource folder. See bellow photo. I want it to go directly to the standard drawable folder, not some other density drawable folders without having to manually change the folder every single time.
Is this even possible?
You can change the View from Android to Project if you are copying & pasting multiple images in a row. You can simply paste it to the drawable folder.

Image in android?

My ImageButton in my app is very tiny and cut off. I realized this could be because the image was in the drawable folder instead of the mitmap folders. So, I copied the images from the drawable folder, and pasted them in mitmap folders. Now, should I go about deleting the image from the drawable folder? I get the following saying it is not safe:
I know how to access the images, but should I delete them from the drawable folder now that I have already moved them to the mitmaps? If I do a delete anyway, will I need to alter my code to access the mitmap image? What is safest to do?
Here is an image of my mitmaps:
Thanks for the expert advice,
Rich
"Not safe" in this context just means that it's still being used somewhere. If you delete it, the current usage will fail to compile, and you'll be easily able to find and alter it to point at the new location.
You can safely delete this image, in Android Studio if you are using this image or else the file will be open at some place, you can get this error actually, so try deleting this image will safely remove the only selected image into your workspace. So hassle free to delete it.
After deleting your image, clear your project and run it, it works fine.
The mipmap folder is used for image that are very small and should be used in the action bar, and other menus. If you find your image too tiny, it just will be worst if you put it in the mipmap folder. If it's tiny although the image is in the drawable folder, maybe the image has a very small dimension or your imageview is too small.

Android XML says image is not found in drawable folder?

I have this code:
android:drawable="#pickuptools.png"
the picture is called pickuptools.png and is inside the folder drawable-xhdpi.
I have tried #drawable-xhdpi/pickuptools.png, pickuptools without the file extension, and many more.
I can't find the picture through the XML.
The XML is located inside the drawable-xhdpi folder.
What am I doing wrong?
Use:
android:drawable="#drawable/picuptools"
You don't need to use #drawable-xhdpi or something. For any resources , you should use resource type(In your case its drawable) and name of the resource.
For further reference, check out this Android page on how to access Resources.

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

Android state file does not find dpi dependent drawable

I have a state file for buttons which worked fine until I put drawables into res/drawable-mdpi.
I had only drawable in res/drawable-hdpi but I want the app to work on all displays.
The state file is placed in res/drawable as I read it on some websites.
That way it is also done by google with the standard drawables but Ecplise keeps telling me that it can't find drawable with value #drawable/button_normal.
The drawables are definitely at their places.
So what am I doing wrong here?
Ok...there was nothing wrong with the code, drawables were not ok.
I made them again, 9-patched them and voilĂ : no comments by eclipse.
Sorry for wasting place for this.
make a folder drawable inside res and put ya pics into that folder. and you can refer to them as
android:background="#drawable/oscar"

Categories

Resources