开发者

Layout Alignment Issues For Device to Device

  1. When I try to run my project on LG Android Mobile then there is no alignment issues come with this device it开发者_运维问答 is a 3.2 HVGA but when I try to run it on Motorola it is a 3.7 WVGA then it gives complete layout alignment issues so can you tell me suggestion to implement layouts uniquely to every device.

  2. I don't know is it possible or not to make a unique layout design for all devices.


You can't create custom layouts for different devices, but you can for different screen densities and sizes, Supporting Multiple Screens has all of the information you should need.


You can create custom layouts by reading the device layout screen like this

Display display = getWindowManager().getDefaultDisplay(); 
int width = display.getWidth();
int height = display.getHeight();

There are two ways you can create your layout. You can create your own algorithm that checks the difference between the resolution you have made your layout for, and gets the difference for the current screen size, and adjust all those values progmatically (long and tedious, but DEFINETELY will work on all devices)

Or, you can define a layout for each of the common devices in your layout folder. This requires alot more space and time though.


Sometimes back I was having this type of problem. Because I was using Pixels as my unit to specify height, width or any layout specific dimensions. But I changed those px to dp and it worked for me. I got same layout for all the screens. Hope if this may help you anyways...


Here is a quick checklist about how you can ensure that your application displays properly on different screens:

1.Use wrap_content, fill_parent, or dp units when specifying dimensions in an XML layout file 2.Do not use hard coded pixel values in your application code 3.Do not use AbsoluteLayout (it's deprecated) 4.Supply alternative bitmap drawables for different screen densities

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜