开发者

Buttons in my App are different sizes on different phones

I am developing an Android App.

I have a few Android Devices and in my Emulator the App looked just how i wanted it. I tested it out on my MyTouch and looked perfect as well. But when i test the App out on my LG Ally the buttons are significantly smaller!

Is there a way to fix this开发者_开发百科?

The App is called PostSecret on the Android Market. You can download it and see what the buttons do on your phone if you want...

I cant post any images yet because of my rank on this site :( But the logo has a black background with a silver border and PS written inside of the logo


MyTouch is having a 320 x 480 pixels screen and a medium density, where else LG Ally is 480 x 800 pixels and high density.

You have to understand the concept of density.

A screen with lower density has fewer available pixels spread across the screen width and height, where a screen with higher density has more — sometimes significantly more — pixels spread across the same area. The density of a screen is important because, other things being equal, a UI element (such as a button) whose height and width are defined in terms of screen pixels will appear larger on the lower density screen and smaller on the higher density screen.

One way is to define your buttons in density independant pixels(dp) instead of px.

E.g. android:layout_width="40dp" android:layout_height="fill_parent"


Easy. Your buttons are scaled in pixels, while the device resolution varies. Try using % or a similar unit, or make the dimensions of each button relative to the width and height of the screen.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜