image shows is unreadable format in eclipse drawable folder - android

When I add an image into the drawable folder, the image shows in text format although the image name is in lowercase.
I tried all the drawable folders, but the error still doesn't go away.

Create a new folder inside res, name it drawable.
Move birthday.jpg to drawable folder.
in xml, set attribute android:background="#drawable/birthday" to your imageView/layout in which you want your image to be displayed.

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

Android Studio's Image Asset Studio won't recognize png file in file system

I have a png file named triedsohardicon.png I want to use for my app's launcher icon, but after putting it in the folder associated with the project, I find that Image Asset Studio doesn't show any triedsohardicon.png in its file system browser in that location.
In addition, if I put the line
android:icon="#drawable/triedsohardicon"
in AndroidManifest.xml (because I did in fact put the png file in the TriedSoHard/app/src/main/res/drawable folder), the text in quotes just returns the error "Cannot resolve symbol '#drawable/triedsohardicon'".
The png has dimensions 512x512. I could use some help, please.
Launcher Icon should be placed in mipmap res\mipmap\triedsohardicon.png
Place your launcher Icon through Image Asset like below:
Upload and Save the png and it will be placed in mipmap automatically.
In Maifest:
android:icon="#mipmap/triedsohardicon"
Hope this helps.

Trouble with adding image source in android studio

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"

Applying Calendar Image to Image Button

I wanted to Display Calendar Icon as a Button In Android. I have created a Image Button as,
ImageButton DtPk = new ImageButton(this);
I know that image will set as,
Drawable d = Drawable.createFromPath("#drawable/calendar");
DtPk.setBackgroundDrawable(d);
But where do i store image in my project? And how.
When the project was created you should see a folder called "res" and inside it several different drawable folders. Place the image inside of the one called drawable-mdpi. Then simple do the following:
DtPk.setImageResource(R.drawable.calendar);
Here is another SO post explaining more about drawable folders: Drawable folders in res folder?
And read the section called Bitmap File in this document: http://developer.android.com/guide/topics/resources/drawable-resource.html

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