Reputation: 943
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.
Upvotes: 3
Views: 3350
Reputation: 16367
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.
Upvotes: 4