2

Maybe a stupid question but in android how can I set aspect ratio in xml (dimens.xml in values folder) to set different aspect ratio depending on devices

I tried :

layout.xml

app:layout_constraintDimensionRatio="@dimen/common_image_aspect_ratio"

values/dimens.xml

<dimen name="common_image_aspect_ratio">3:2</dimen>

but it doesn't seem to work.

Any help would be appreciated, thx :)

Phantômaxx
  • 37,352
  • 21
  • 80
  • 110
sokarcreative
  • 516
  • 7
  • 17

1 Answers1

5

Try to write 1.5 instead of 3:2. Generally, you should use decimal format, not fractional. Hope it will help.

Muhammadjon
  • 1,418
  • 2
  • 13
  • 34