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

Richard Graham

07/26/2021, 6:29 AM
Update: managed to fix this - it looks like if you're going to combine the old UI system with compose with something like this:
Copy code
fun bind() {
            binding.root.apply {
                findViewById<ComposeView>(R.id.filter_button).setContent {
                    Random.Theme {
                        FilterButton()
                    }
                }
            }
        }
Adding anything like padding or margin to the filterButton defined in XML will cause the element to re-render each time it is updated. E.g This works:
Copy code
<androidx.compose.ui.platform.ComposeView
        android:id="@+id/filter_button"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>
This doesn't:
Copy code
<androidx.compose.ui.platform.ComposeView
        android:id="@+id/filter_button"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="6dp"
        android:paddingTop="@dimen/find_match_transactions_header_top_padding"
        android:paddingEnd="@dimen/material_cell_side_padding"
        android:paddingBottom="@dimen/find_match_transactions_header_bottom_padding"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"/>
👍 1
🙏 1
2 Views