In my android app a have a screen with a huge scro...
# compose
b
In my android app a have a screen with a huge scroll. It has everything: embedded html, images, texts, a custom composable that renders QRs... I want to add a button to create a screenshot of that screen. I found different solutions but I don't like them too much. Compose is a declarative way to render a screen. I should be able to create something like this
val bitmap = screenshot { content() }
.
screenshot
is not a
@Composable
function. It is just a regular function that returns a
Flow<Bitmap>
or just a suspend function that returns a single
Bitmap
. What I'm looking for is something similar to what paparazzi does but inside android, pass a composable to a function and it generates an screenshot of it. Is this possible? Is it done already? How hard could it be to develop?
a
s
People have used a similar approach in this case. It may not be the most efficient solution, but it gets the job done. (Android only) https://kotlinlang.slack.com/archives/CJLTWPH7S/p1715715563708939?thread_ts=1715677194.944999&amp;cid=CJLTWPH7S
b
VirtualDisplay
, that sounds promising! I will check that thread 🙂
Andrey that solutions works for me with simple composables but with webviews, LazyColumns and similar things it doesn't work that good :(
🤦‍♂️ headless! That was the missing keyword in my google search.
a
Might be worth having a look at
ImageComposeScene
. I think it's desktop only but it sounds like what you want
s
@Alex Styl
ImageComposeScene
is on all targets except Android (part of
skikoMain
). Wondering what would it take to get implemented on Android, it's a super convenient headless API.