Android Screen Issues
i am new to android development. I use the eclipse with android plug-in and just made an application on 2.1(update) platform. I deployed it on two different handsets both with OS 2.2. I made use of absolute layout, and gave required paddings in portrait and landscape modes by specifying all dimensions in pixels(i am using layout-land folder for landscape xmls). Now the problem is that in one of the phones with smaller screen size, in landscape mode, part of the page wont come, i.e. it goes out of the screen and i cant see or access that part of page. I want to be able to develop in such a way that in any phone, with any screen size, in any view mode(portrait or landscape) my page should align itself acco开发者_Go百科rdingly, and all should be seen. Whats the best way to achieve this?? Thanks in advance
I think you need to start out with the basic android recommendations:
- Don't use pixels - use dp or sp depending on your context
- Absolute layout is the least flexible and intelligent of your options, it is very unclear in which situations it would be your first choice.
I would try to use Linear Layouts and relative layouts as far as possible, as they generally play better under differing screen circumstances.
However for a really professional look I would highly recommend that you define multiple screen layouts for a few typical screen sizes and both orientations. Androids internal support for this makes it very worth the effort.
If your xml files contains any images then make sure to make four sets of images to support all the devices that is the low density, medium density, high density and extra high density. Do not specify widths or heights to the views just give wrap_content
or fill_parent
wherever necessary and also use Relative Layout
for better designing of UI. That will solve the issue and your code will run fine on any device.
Use relative layout and don't specify height & width instead use fill_parent or wrap_content which ever is appropriate.You can show your code for more clarity.
Dont use absolutelayout. It won't be very much useful for Android as there are thousands of devices with different screen sizes. I would suggest you to stick with LinearLayout
精彩评论