https://kotlinlang.org logo
#compose
Title
# compose
t

Travis Griggs

10/19/2023, 8:47 PM
Given:
painterResource(<http://R.drawable.my|R.drawable.my>_resource)
Is it possible to get any sizing info about the resource? In particular, I want to know the aspect ratio of width / height (so I don't really care what units the width|height would be)
a

ascii

10/19/2023, 8:55 PM
.intrinsicSize
should get you there. The only two possibilities for a painter resource would be bitmap or vector I think, and both
BitmapPainter
and
VectorPainter
would return a proper size, not Size.Unspecified
e

ephemient

10/19/2023, 8:58 PM
some painters may be unsized in one or both dimensions, and https://google.github.io/accompanist/drawablepainter/ may return some. but yes,
androidx.compose.ui.res.painterResource()
only supports bitmap and vector drawables, which are finite sized