tags:

views:

831

answers:

1

Hi All,

I need to implement a screen containing a list of blocks one below the other. Each block will contain mutiple superimpose elements (Images, text) for which the relative position needs to be specified with respect to the top left corner of the block.

For creating the list of blocks i have used listview. For each block i tried to use relative layout.This works ok when the phone is in landscape mode and absolute position is specified relative to left edge of the phone. But when the phone is put in the portrait mode the layout gets distorted.

1) What layout can be used for this scenario?

2) Can relative positions be specified in terms of percentage of screen width/height instead of pixels?

+1  A: 

You can use different layouts for portrait and landscape mode in folders "layout-port"/"layout-land", which will be auto-loaded on screen orientation change. Check the docs or some of the Android books for thorough explanation how Android resolves the folder with best matching resources.

As of now, the closest thing to percentage width/height is the LinearLayout.LayoutParams' layout_weight, which determines how much of the remaining space (from 0 to 1) to be occupied by the given view/element.

Dimitar Dimitrov
Please mention name of the books where i found "Android resolves the folder with best matching resources". There is no other option instead of creating "layout-port"/"layout-land" folders
Jitu