AndroidStudio background image

Hi all.
I'm starting with AndoridStudio just now. I want to leave App Inventor because of its limits on dynamic contents and because I prefer manipulate directly the code instead of Blocks which have many limitations.
So, I was trying to set a background image for my main Activity, but the message is:

Couldn't resolve resource @drawable/tortugas
Failed to convert @drawable/tortugas into a drawable

I also tried to set backgroundTint, but I get a warning saying backgroundTint is only used in API level 21 or higher and any color I try to set
 raises a warning saying the resource is marked as private and anyway the color doesn't appear. Even setting the colo using the color picker doesn't change the look of the emulator. What am I missing?
I read the manual 'Android Studio Essentials' but I didn't find anything about this and what I found surfing the web is unuseful: I yet follow those guidances but with no result...

Thank you in advance
LVL 32
Marco GasiFreelancerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Chris Harte2015 Top Expert (Most Article Points)Commented:
The failed to convert usually means there is an illegal character in the file name such as hyphen, android is very picky about this. And it has to be the right file type. The documentation says it has to be a bitmap which it defines as a .jpg, .png or .gif. Notice the absence of .bmp

(If you are on linux it could be a permissions thing, but I would not have thought so).

Your api level is set in the manifest file. If you want to develop for a range of android you are going to come across a lot of deprecated/not yet implemented methods.  Lollipop was a major update with a lot of new classes and methods, such as setBackgroundTint. If you are learning android or just developing for yourself, set your api range to the highest it will go (currently 21 to 23) backward compatibility should only be done if a customer insists on it. Android is free, let them upgrade. A lot of the features on lollipop are not available in older versions of android and it would be shame to miss out on them trying to write an all encompassing app. Writing an app that implements different classes depending on the api is a huge, unforgiving, undertaking.

The private issue one I have not come across before, try cleaning the project, refreshing the directories in the Package Explorer and if all else fails, restarting studio (you never know).

These are a very good tutorial

I used to recommend books, but between buying it and getting it home, it will become out of date.

Try eclipse with ADT, personally I prefer it to AS, but I had to run them both to find out.
Marco GasiFreelancerAuthor Commented:
Thank you very mutch for your reply, MunterMan. I'll follow the tutorials you suggest.
About the image, its name is tortugas.jpg: no hiphen or strange symbols at all. I copied it in c:\Users\Marco\AndroidStudioProjects\MyApplication\app\build\intermediates\exploded-aar\\appcompat-v7\23.0.0\res\drawable\ (yes, I'm on Windows) and I've set it up using  the Properties panel. Is a normal jpg image resized with Photoshop to 480x720 and Saved for Web... I'll try with other images... But why I can't see the background colored with my custom color?
Chris Harte2015 Top Expert (Most Article Points)Commented:
Layouts are my real weak spot and android is not very helpful with this. In the XML design tab, have you tried changing the theme? This does a lot more than I would expect and has solved weird problems for me in the past, especially using the Holo dark or light themes.

I notice you are using the compatV7 library. This is for backward compatibility. When I tried to use it I got a lot of conflicts and loading of the wrong libraries, particularly when trying to use fragments. In the manifest set your target sdk version to 22 or 23, comment out the imported v7 headers and when prompted, import the standard java/android libraries.

As for images, I do not "save for the web" I just save normally, with low detail to keep the size down. Also, android recommends using png files rather than jpeg. (I use jpg).

These changes should not make a difference, but get it working in vanilla first before trying anything exotic
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Marco GasiFreelancerAuthor Commented:
Hi. I started a new project setting it just for Lollipop and now I can't find drawable folder at all :-). Hope tutorials will make me find my route through this jungle...
Chris Harte2015 Top Expert (Most Article Points)Commented:
It is no longer called drawable, for screen size compatibility they are called drawable-*. Load all your graphics into drawable-hdpi, that is the default.
Marco GasiFreelancerAuthor Commented:
Lol. Ok, I can't find drawable-hdpi but I saw my previous search was partial. Now starting the search from the root of the app I find drawable in a totally different path: c:\Users\Marco\AndroidStudioProjects\BuceoRinonDeArona\app\src\main\res\drawable\ Put there my images and set the background: no error, backgroundTint becomes magically visible, image remains hidden. It's amazing!!! :-D
But, wait... empting backgroundTint property makes visible the image background.

I'm used to other languages and tools so I find strange some working logic of this IDE. Is Eclipse different ()I don't understand why setting a bacground color have to make the background image invisible)? And what about Netbeans IDE (I yet use it in Php)?
Chris Harte2015 Top Expert (Most Article Points)Commented:
tint OR backgroundimage I think you will find. You are setting a resource to be either an image or a colour.

Though if you try tinting it in code you may get better results. Use the colorfilter() method on your image

private ImageView tortugas;

tortugas = (ImageView) findViewById(; //name of the image in your xml

tortugas.setImageResource(R.drawable.tortugas);//name of the image file without extension
tortugas.setColorFilter(Color.argb(255, 255, 255, 255);//white tint

Open in new window

My personal preference is to use code rather than xml.

I find eclipse less cluttered than AS, and I use it with php as well. I do not like NetBeans and I have tried it with Java, Php and android. However, if that is what you are used to you may find it better. Try it, it can not be any worse than the results you are currently getting.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Marco GasiFreelancerAuthor Commented:
I'm moving on from AppInventor because I prefer code too... but I'm a novice in Java so...
I think you'll find my other question in the near future.
Chris Harte2015 Top Expert (Most Article Points)Commented:
No problem, but I found it a very steep learning curve and I came with some java experience. These are getting a little bit dated, but updating deprecated methods is what it is all about. It is where I started.
Marco GasiFreelancerAuthor Commented:
Thank you again for the help :-)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.