Good afternoon/good morning. I have a question abo...
# compose
c
Good afternoon/good morning. I have a question about adjusting the accompanist Dialog to look similar size(almost the same) look in different devices. How can I achieve this?
The first one is like this..
Copy code
device = "spec:shape=Normal,width=1920,height=1280,unit=dp,dpi=230")
2nd, 3rd one is Okay. But 1st one is too small.
Screenshot 2023-05-26 at 3.55.51 PM.png
Oh, It's not accompanist but just Dialog from Jetpack compose.
t
In my experience it is better to not use the Dialog from Compose (It creates a new window) instead just build your own with normal compose components because there are still some glitches. And you than have more control over every thing.
c
Hmm.. Okay.. 😞 I actually changed from my custom function to Dialog. That's sad. I can change the Theme but I think the window size is limited.
t
It is possible to get the dialog working for the whole screen. Let me search my other projects to see how i solved this.
c
Thank you 🙂
t
So the solution was to use
Copy code
DialogProperties(usePlatformDefaultWidth=false)
And than use compose to fill the whole screen.
c
I tried it too and I think this only works in old version.
t
Not sure if this still works as expected. But just used this because it was in a project with mixed legacy and compose view system. So i needed a way to paint above the legacy layout.
c
I just used Box with background + alpha and clickable at the moment.
t
Just checked and for me it works also in Compose 1.4:
Copy code
Dialog(
    onDismissRequest = { /*TODO*/ },
    properties = DialogProperties(usePlatformDefaultWidth = false)
) {
    Box(Modifier.fillMaxSize().background(Color.Red))
}
This will fill the whole screen with red.
c
I am using bom 2023.01.00 and it doesn't work.
c
I thought you could'n't preview dialogs in compose?
c
Dialog? It's just composable function and it is displayed in preview.