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

matt tighe

11/21/2019, 6:20 PM
Can there only be one
@Preview
function and does it need to be in the main activity?
z

Zach Klippenstein (he/him) [MOD]

11/21/2019, 6:21 PM
You can have as many preview functions as you want in whatever files you want - when that file is open, it will show all those previews together at once.
m

matt tighe

11/21/2019, 6:22 PM
Odd. If I paste my preview into the main activity it displays, but it doesn't if I define it in a new file
z

Zach Klippenstein (he/him) [MOD]

11/21/2019, 6:25 PM
I think there's a bug where you need to reopen the file the first time you add a preview function
m

matt tighe

11/21/2019, 6:25 PM
Yep, that did it. Thanks!
l

Leland Richardson [G]

11/21/2019, 6:29 PM
yep. that bug (i think?) is fixed on the latest canary build of studio, but i could be wrong
l

Luca Nicoletti

11/22/2019, 8:44 AM
How far you see the preview if your function in an activity? Preview are meant to be top level functions 😧
l

Leland Richardson [G]

11/22/2019, 6:43 PM
i think perhaps he meant that it was in the same file. the IDE basically looks for the presence of @Preview when the file is opened, but doesn’t check after that