Office Hours — Today, August 12

Thursday, August 7

Aug 12
7:20 PM
Mark M.
has entered the room
Mark M.
turned on guest access
8:00 PM
Gabriele
has entered the room
Gabriele
Hello Mark!
Mark M.
hello, Gabriele
how can I help you today?
Gabriele
I had a question about drawables and resources and then another about applying layouts to screen sizes
8:05 PM
Mark M.
go right ahead
Gabriele
So I have buttons, I created drawables for them in photoshop and I created it according to mdpi for the size (the resolution was something like 74) and it was all good.
Mark M.
these drawables are the background? or are these ImageButtons?
Gabriele
background
I just wanted to make sure that in order for me to have those drawables be represented well in the other dpi's is to change their size, and resolution in photoshop.
so whatever they were in mdpi, multiply that by 1.5 so it will be good for hdpi
Mark M.
well, first, I'm not a Photoshop user, so I can't provide any specific instructions
second, usually a button background is a nine-patch PNG, so it can stretch to fill whatever is in the foreground
(actually, a series of nine-patch PNG files, for different states)
you don't *have* to use a nine-patch PNGs, but that's what the standard buttons use
Gabriele
Yeah, i tried 9 patch and it lost some of the photoshop effects so i tried with just a normal ong
Mark M.
well, bear in mind that if Android has to stretch those PNGs to deal with your foreground, those "photoshop effects" may get screwed up that way too
all that being said, yes, saving the image in different resolutions based upon density changes is the right recipe
for whatever densities you want to ship
Gabriele
sweet!
Mark M.
everything else, Android will resample (again, with possible harm to your effects)
8:10 PM
Gabriele
thats cool i guess, if its small
so for the layouts part
I have been testing these on emulators and of course the larger screened emulators place the widgets that aren't MATCH_PARENT in the wrong spot. How can i compensate for as many screens as possible?
Mark M.
I can't really answer that
Gabriele
a little misplacement is fine, but not when its totally wrong
snap
Mark M.
that's all tied into your layout definitions
and your fragment strategy, if relevant
Gabriele
i havent used any fragments
is that a problem?
Mark M.
layouts are usually flexible enough to handle modest size changes (e.g., 4" to 5" screen)
for larger changes (e.g., phones to 7" tablets to 10" tablets), you need to have a strategy
but I can't help you with that, because I don't know your app, your UI, or your objectives
Gabriele
understood
Mark M.
there's a chapter in the book on large-screen strategies and tactics that gets into this sort of thing
8:15 PM
Gabriele
I found on some stack overflow question that you, if you were trying to cover all screen sizes or specify which ones you wish your app to function on, mention it in your manifest somehow. Is defining the screen sizes your app will support in the manifest a must?
Mark M.
you are probably referring to <supports-screens>
Gabriele
yes!
Mark M.
for tablets, the two relevant attributes are android:largeScreens and android:xlargeScreens
setting them to true means that you have explicitly written support for those screens in your app
setting them to false means that Android should use iOS-ish "pixel doubling"-type techniques to zoom your UI to fit the space
that's the so-called "screen compatibility mode": http://developer.android.com/guide/practices/sc...
usually, that's not what you want, if you want a nice-looking UI
which means usually you want to set them to true
Gabriele
for phones as well?
8:20 PM
Mark M.
android:smallScreens and android:normalScreens are true by default
for smaller screens than you support, false is a filter
so I often set android:smallScreens to false if I am not going to try to take the time to figure out how to squeeze my UI into a < 3" screen
then, apps with such screens cannot install the app
Gabriele
i feel ya
are large screens 7" and up?
Mark M.
there's official definitions in the docs in terms of dp on each axis
roughly speaking:
small is < 3"
normal is 3-5"
large is 5-10"
xlarge is > 10"
Gabriele
well alright
well thats all i got for you Mark. thanks for the info!
Mark M.
you're welcome!
Gabriele
has left the room

Thursday, August 7

 

Office Hours

People in this transcript

  • Gabriele
  • Mark Murphy