Icons for different size/res. devices

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

jo1234

Active Member
Licensed User
Longtime User
Hi,

I tried to follow your steps, but it didn't work.

I have created the directories
\Objects\res\drawable\drawable-ldpi
\Objects\res\drawable\drawable-mdpi
\Objects\res\drawable\drawable-hdpi

and put a read-only png of the respective size (36x36, 48x48, or 72x72) in. All files are named icon.png.

When I run the app on my wildfire s (480 x 320px), it uses only the icon from the main folder \Objects\res\drawable\ but not the one from the folder \Objects\res\drawable\drawable-mdpi, or any other the subfolders (icons in the subfolders are marked with a letter in the icon).

How come? :confused:

thanks a lot,
Johannes
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
One possibility is that the original icon is the same scale as your device, in which case it would be used rather than one from the other folders (I think).

I just tried it on mine again and it works, but I'm using the size folders and you're using the density folders. Before I tried it, I did like you and modified the icon in the xlarge folder (for my 10" tablet) and the modified icon is what's being used.

The two obvious mistakes would be not having all the icon names the same and not having them read-only, but you said you took care of both of those, so I don't know what to tell you.

I thought of one more thing -- I believe that this only works with Android 1.6 (API Level 4) and up. What version of Android are you running?
 
Upvote 0

jo1234

Active Member
Licensed User
Longtime User
Yes, all files are named icon.png and are read-only.

But the icons in the folders

\Objects\res\drawable\drawable-ldpi
\Objects\res\drawable\drawable-mdpi
\Objects\res\drawable\drawable-hdpi

are ignored. The app always uses the icon from \Objects\res\drawable.
If I delete it, it gets recreated.

I'm using Android 2.3.3 on a HTC Wildfire S.

Has anyone used icons of different resolutions successfully?
 
Upvote 0

jo1234

Active Member
Licensed User
Longtime User
Solved.

The icons must be in
\Objects\res\drawable-ldpi
\Objects\res\drawable-mdpi
\Objects\res\drawable-hdpi
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
Stupid (?) question.....

Currently I am using the same image files (png) for all of the layout variants in my app (most buttons use custom images). They are all somewhat large images (dimension-wise) with the idea being that they will scale down on smaller screens yet still look crisp on larger screens like tablets.

One thing I am wondering though, is on smaller devices, I wonder if it creates too much unnecessary overhead to have these larger images scaled down and possibly slowing the app down which could lead to a force close if it takes too long to load in?

Can I also put different sized copies of my resource PNGs in the folder mentioned here, or if not, where would I put them? When compiled, my button images are in the 'assets' folder within the APK.

I am wondering how I would go about specifying different images for different screen sizes, similar to how it is done for the shortcut icon. Or is the only solution to use different filenames and use those different filenames in the layout variants?

A user of my app complained of a force close and the only time I ever saw a force close during development was when I was playing with tablet AVDs in the emulator on my slower notebook computer. I figured that was understandable as the emulator is slow, but I don't want this to happen in real life if I can prevent it.

EDIT: I'm reading up a bit on force closing with 5 seconds of no response and it stated "Do not do long processing on the UI thread". Is there some way for me to have the layouts loaded using a different thread from the main thread? Sorry, but I'm not too familiar with threading.
 
Last edited:
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
You could use code similar to what's shown here to load different sized graphics files. I don't know the answer to your loading time question. I've got a pretty large app, and I've never gotten a forced closed when loading. A couple of times I've gotten a forced close in the middle of running the app, but it rarely happens and is not repeatable, and my tablet has shown an inclination to be flakey at times, so I'm trying not to worry about it.
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
If I read the link right (it's late and the Ambien isn't working, lol), I don't know that it would be much different in that I'd still be loading a new layout for each custom interface, although that may make it easier to at least specify different (sized) image files.

The couple FC I experienced in the tablet AVD were random as well, and not when loading for the first time.

The feedback I got on the FC was one comment in the market, basically 'sux. Won't even load. Force close.' In other words, typical negative comment with no helpful info at all. On the other hand, over 800 installs and only two crash reports, unrelated. I see complaints of FC in other app comments all the time, and there is no way to know if they have a known crappy phone, or other stuff running on it that causes these problems.

It was just a thought, that maybe the large graphics are the problem, and I'm trying to find ways to speed things up now.

Thanks for the response though. I'll look more at it tomorrow.
 
Upvote 0
Top