I want to support both small screens and large screens
I have an image view in my layout - that in small screens it needs a layout height of "wrap_content"
and in large screens it needs 400dp (wrap content is too small)
instead of creating another layout, i wanted to create a dimension
<dimen name="layout_height">wrap_content</dimen>
<dimen name="layout_height">400dp</dimen>
and assign them to the right folders and in my imageview write
layout_height=@dimen/layout_height
is this possible in any way, without creating another layout ?
To assign wrap_content or match_parent from resources you need to create these items in dimens.xml file:
<item name="match_parent" format="integer" type="dimen">-1</item>
<item name="wrap_content" format="integer" type="dimen">-2</item>
Then you can simply use it like this:
<dimen name="layout_height">@dimen/wrap_content</dimen>
you can have a different style
for small and large screen, overriding the layout_height
property. Unfortunately you can not set wrap_content
inside dimen
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With