1

How can I get the width and height of an image in NativeScript?

I've tried referencing like:

<Image src="~/assets/images/logo.jpg" ref="img1"/>

And getting the width like:

this.$refs.img1.getMeasuredWidth

But no luck.

panthro
  • 22,779
  • 66
  • 183
  • 324
  • 2
    If you want to get the actual width and height of your image, you should use ImageSource module. If it's the rendered image component's width you are looking for, wait for layout event and then read the measured width and height. – Manoj Feb 04 '20 at 19:55
  • 1
    Could you show an example? – panthro Feb 05 '20 at 08:38
  • 1
    Can you confirm which one you are looking for, the Image component height on screen Or the actual image's height. – Manoj Feb 05 '20 at 15:51

0 Answers0