i have a list adapter for my list. the list item is created by inflating a layout which has a relative layout with 50dp height. i want to change the height of the relative layout to be wrap content on orientation landscape and in portrait it be 50 dp. how can i achieve this?
Share
Create one folder in the
resfolder calledlayout-landfor landscape mode. Inside that folder rewrite your xml file with height as wrap-content. In the xml of layout folder keep the height as 50 dp.Example: let say you have relative layout in
abc.xmlinsideres\layoutas given:Create
abc.xmlinsideres\layou-landas given below:If you are in landscape or portrait Android looks for the layout file in either the -port or -land directory first, if it’s not found then it falls back to the default layout directory.
You can read about providing alternative resources here. There are many more options than just land and port.