Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialEdward Mosley
663 PointsAdd image via xml: error
Hello,
I've been trying to add an image to my program via xml (since I can't do it via layout since I'm having rendering problems) and I keep getting an error. Here is the code that I used:
android:src="@drawable/main_title.png"
And I have the image in the proper folder, so now I'm stuck.
Any help would be greatly appreciated.
2 Answers
Simon Coates
28,694 Pointsi just created an image inside android studio\drawables. Image was called plonk.bmp. Was able to access it with android:background="@drawable/plonk". So maybe try without the file extension.
Edward Mosley
663 PointsThanks for the response. I tried and got this response: Error:(20, 22) No resource found that matches the given name (at 'src' with value '@drawable/main_title').
Simon Coates
28,694 Pointssorry i couldn't help. My images (.bmp, .png) are definitely in the res\drawable folder and I was able to use src or background attributes to access them without the extension.
Edward Mosley
663 Points@Chris Vaughan, this is the error: "Error:(20, 22) No resource type specified (at 'src' with value '@drawable\main_title.png')."
christopher vaughan
1,411 Pointschristopher vaughan
1,411 Pointswhat error are you getting??