https://kotlinlang.org logo
Title
s

Sean Proctor

04/12/2023, 6:08 PM
Did
AndroidView
or
Modifier.weight()
change behavior in Compose 1.4? I have an
AndroidView
in a
Column
that I want to fill the remaining space. With Compose 1.3 this does what I want. With Compose 1.4, the
PreviewView
fills the entire screen.
Column {
    AndroidView(
        modifier = Modifier.weight(1f),
        factory = { context ->
            PreviewView(context).apply {
                layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)
                implementationMode = PreviewView.ImplementationMode.COMPATIBLE
            }
        }
    )
    SomeOtherContent()
}
Changing to the following fixed my issue:
Column {
    Box(Modifier.weight(1f)) {
        AndroidView(
             factory = { context ->
                 PreviewView(context).apply {
                     layoutParams = ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT)
                     implementationMode = PreviewView.ImplementationMode.COMPATIBLE
                 }
             }
         )
    }
    SomeOtherContent()
}
s

shikasd

04/12/2023, 6:43 PM
It's a bug, should be fixed in 1.4.1, I believe