Jump to content

  • Log In with Google      Sign In   
  • Create Account


[android 2.2] UI is different on emulator than on a device


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 sheep19   Members   -  Reputation: 382

Like
0Likes
Like

Posted 10 December 2011 - 11:42 AM

I have started android development recently. Today I made a simple UI menu with some buttons and a text label.

However on the emulator is a bit different than on an actual android device (HTC Desire HD). To be specific, the buttons on the mobile device appear a bit more upwards than on the emulator.
Why is that? Is that expected from the emulator or does this imply that my UI will be different (from the current tested phone) on other phones?

I have used dp for the positions for the buttons and sp for their text size like suggested on android developer website.
--------------Visit My Website

Sponsor:

#2 frob   Moderators   -  Reputation: 16138

Like
0Likes
Like

Posted 10 December 2011 - 06:25 PM

The manufacturers are able to customize the system for their device. Many of them will swap out system buttons, the system keyboard, and other elements.
Check out my personal indie blog at bryanwagstaff.com.

#3 Don Carnage   Members   -  Reputation: 608

Like
0Likes
Like

Posted 11 December 2011 - 07:21 AM

How did you configure your emulator? Quick googling suggested an optimal configuration for Desire HD (below). Did you use those?

http://stackoverflow.com/questions/6149748/htc-desire-hd-android-sdk

http://stackoverflow.com/questions/5703124/the-correct-eclipse-android-device-configuration-for-htc-desire
It is I, the spectaculous Don Karnage! My bloodthirsty horde is on an intercept course with you. We will be shooting you and looting you in precisely... Ten minutes. Felicitations!

#4 sheep19   Members   -  Reputation: 382

Like
0Likes
Like

Posted 12 December 2011 - 09:26 AM

Thank you for your answers.

I read an article on android developers website. It stated that I should use dp and sp so that UI will look the same on all devices with different screens. That's what I did, and here's the result:

Left side: HTC Desire HD
Right side: HTC Wildfire


Posted Image

Why is that?
--------------Visit My Website

#5 frob   Moderators   -  Reputation: 16138

Like
1Likes
Like

Posted 12 December 2011 - 10:32 AM

You are working with the system in a "Please do the layout for me" mode. This is great for text-based stuff that uses minimal graphics.

Consider that the two have physically different screen ratios.

One is 800x480, or 5:3.
One is 320x240, or 4:3.

The platform is really good at scaling, stretching, and otherwise manipulating the screen to fit various devices.

If you have text it will make the text big enough to read on the huge tablets, or small enough to fit on the small phones. It will keep it centered and give a generally pleasant layout across a huge variety of devices.

That is great for anything that mostly uses text, or has minimal use of pixel-perfect graphics. It will work great for simple line drawings and graphs and other general use graphics.



But many games want pixel-perfect alignment. Resizing, scaling, and otherwise manipulating layout in such games can be detrimental.

Many games will tweak their UI code to specifically support the more common screen ratios of 4:3, 5:3, 16:9, and 16:10. They will also often normalize their view rectangle so it exists from 0.0 to 1.0, or from -1.0 to 1.0, so that it accommodates large and small displays, and can be easily extended to new form factors.
Check out my personal indie blog at bryanwagstaff.com.

#6 robobrain   Members   -  Reputation: 106

Like
0Likes
Like

Posted 14 December 2011 - 04:36 PM

Thank you for your answers.

I read an article on android developers website. It stated that I should use dp and sp so that UI will look the same on all devices with different screens. That's what I did, and here's the result:


dp and sp really only work with text sizes, buttons, etc. Things that can have a discreet size assigned to them. keep in mind that dp and sp will mean that the interface elements look the same size on any screen. It does not mean they will be scaled proportionally. in other words, 160 dp on a 160dpi screen will equal 160pixels, but on a 72dpi screen it will equal 72pixels. Android only makes sure that they both measure out to about an inch in the real world.

The only way to make sure it looks good, in vanilla Android, is to design different layouts for different screen densities.
Want to make Android Games?
Then check out the free RoboBrain SDK.
www.robobrain.org

#7 jonbonazza   Members   -  Reputation: 121

Like
1Likes
Like

Posted 14 December 2011 - 05:17 PM

I highly recommend watching this video. The lead UI programmer from Square Inc. does a great job of covering just this and much more.

Co-founder/Lead Programmer
Bonafide Software, L.L.C.
Fairmont, WV 26554 US




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS