Office Hours — Today, January 27

Thursday, January 14

Mark M.
has entered the room
Mark M.
turned on guest access
Jan 27
3:55 PM
Steve
has entered the room
Steve
Hi, Mark
Mark M.
hello, Steve!
how can I help you today?
Steve
I have some questions about Pixel Perfect. Here they are:
View paste
I have some Sketch files and exported PDFs of screen mockups from a designer. I'm trying to create layouts that match the mockups, and have been trying to figure out how I can do that. I've been looking at Hierarchy Viewer with its "Pixel Perfect" functionality and have some questions.

1. Is this the best tool to use, or are there others I should use instead?

2. When I run the command-line version of Hierarchy Viewer, it says it's deprecated and that I should use the Android Device Monitor instead. However, when I ran that I couldn't find the Pixel Perfect functionality. Is it in there?

3. I can see X and Y values in "px" units when I click on the app screen displayed in the Hierarchy Viewer. How do I convert those values into ones I can use to create the layout in xml (or code)?

4. I can load an overlay into the Hierarchy Viewer, which then replaces the app screen previously displayed. However, I can't see the underlying image regardless of what I set the transparency (overlay) value to. How do I fix that?

5. Can I use Pixel Perfect to modify a layout directly, or is it rather a way to make measurements that I can then apply to modify layouts in Android Studio?
Mark M.
5. No, you cannot modify layouts
Steve
Ok
Mark M.
3. That's up to you. You know what density the emulator is set for, so you need to do the back calculations to derive dp from the px that you see.
4:00 PM
Steve
Ok. Is there anyplace in your book where you talk about how to make those calculations?
Mark M.
um, it's just division
Steve
Ok.
Mark M.
1 dp = 1 px for mdpi screens (~160dpi)
there's documentation outlining the dpi values for the different density buckets, and that should be in the book somewhere as well
Steve
Great.
Mark M.
so, if your emulator is emulating xhdpi (~320dpi), then 1dp = 2px, and so to get dp from px, divide the px by 2
in terms of 1/3/4, I have not used "Pixel Perfect" in ~5 years
other than the occasional light bit of poking around
Steve
Sure. Then let me back up and ask a general question.
What would you recommend for trying to create layouts that match what a designer has provided?
Mark M.
IMHO, that's somewhat the designer's job
giving you plain screen mockups is tantatmount to useless
er, tantamount
the designer needs to give you rules for sizing, not static imagery
those rules need to take into account screen size and density variations
Steve
That's very helpful. Can you say quickly what a couple of those rules might look like?
Would they use proportions?
4:05 PM
Mark M.
"this button should be 8dp from the left, 8dp from the top of the row"
"this label should be 8dp from the right side of the button"
Eric S.
has entered the room
Mark M.
and so on
Steve
I see. Do you know of any tools a designer can use to provide such rules?
Mark M.
for example, the designer might have a Photoshop layer with annotations outlining the rules
Steve
He's using Sketch.
Mark M.
I don't even know what that is, sorry
Steve
Great. This is helpful. I'll speak to the designer about this.
Mark M.
in which case, I would recommend written instructions, using the diagram merely as a reference and a guide to what things should look like, more or less, when the work is done
let me take a question from Eric, and I'll be back with you in a bit
Steve
Thank you. I have an idea of how to proceed.
Mark M.
Eric: your turn! do you have a question?
Eric S.
Hi!
First I just wanted to thank you for the "Stack Overflow Bump" feature - you have answered two of my questions and it's been very helpful
Mark M.
I'm happy to be useful!
Eric S.
I had a quick question about emulators - I was curious what people are mostly using these days
I have started using Genymotion
I know that Intel ships one that Google distributes
But it is incompatible with Docker when i attempt to run it on OSX
Mark M.
Genymotion is fairly popular, though I expect that most developers stick to the one with the Android SDK
Eric S.
Are there any others that I should consider for running locally, that you have seen in use?
Previously I had been using a physical device
Mark M.
not that I can think of off the top of my head, unless you consider android-x86.org to be an emulator
Steve
has left the room
Eric S.
I have not heard of android-x86.org -- I will check that out
Mark M.
note that the Android SDK emulator is being overhauled for Android Studio 2.0, which may or may not impact your Dockerization
as the name suggests, it's a build of Android that runs on x86
4:10 PM
Mark M.
it's designed to be run from a USB stick or installed on hardware
in principle, you should be able to run it in a VirtualBox or equivalent
Eric S.
Are you doing any development in Android Studio 2.0 now, or would you recommend it's use?
Mark M.
I don't touch pre-release stuff from Google
re-phrase that: I don't touch pre-release tools from Google
Eric S.
OK
Mark M.
my life is complicated enough as is
that being said, there are a fair number of people using it, and I'm not hearing above-average screams of anguish
Eric S.
I'd love to be able to use a fast, integrated, compatible-with-docker emulator, so I will check it out
& let you know at a future Office Hours
Mark M.
if you don't mind my asking: why do you want an emulator to run in Docker?
Eric S.
I use docker to emulate my server as I do development locally on my MacBook Pro
The Android emulator itself need not run in Docker
However
The Intel Emulator is somehow incompatible with Docker
Whereas Genymotion, which requires docker, works just fine
err
Sorry
Intel is incompatible with VirtualBox
Genymotion uses VirtualBox
VirtualBox is also used by Docker
Thus, whatever Android emulator I use needs to play nice with VirtualBox so I can also run docker so I can emulate my server and do proper testing/development
4:15 PM
Mark M.
perhaps things are different on OS X, but your emulator/VirtualBox problems shouldn't be an Intel thing, but just an Android SDK emulator thing, because the Android SDK emulator uses qemu
oh, no, wait
:: continues dusting off unused corner of synapses ::
well, on Linux, I think the problem was qemu/KVM with x86 conflicting with VirtualBox; I suppose that would translate to HAXM on OS X
I would not be surprised if the rules here change with the next-gen emulators coming with Android Studio 2.0, as they said that the emulators emulate multiple cores now, and that might require new qemu bits or something
Eric S.
Yah I'm Googling it now and see chatter on that -- https://software.intel.com/en-us/forums/android...
4:20 PM
Eric S.
I'll checkout Android Studio 2.0 and see how it works
But it sounds like I'm not overlooking any commonly used tools right now
Mark M.
Reto Meier recently posted some stuff on how best to have Android Studio 2.0 alongside another Android Studio installation
but, yes, I am not aware of any other frequently-used emulator-ish thing
Eric S.
Great, thanks so much!
4:25 PM
Mark M.
if you have another question, go right ahead
4:40 PM
Eric S.
has left the room
5:00 PM
Mark M.
turned off guest access

Thursday, January 14

 

Office Hours

People in this transcript

  • Eric Silverberg
  • Mark Murphy
  • Steve