ubu
04/09/2021, 12:25 PMclass SomeWidget : ConstraintLayout {
constructor(
context: Context
) : this(context, null) {
}
constructor(
context: Context,
attrs: AttributeSet?
) : this(context, attrs, 0) {
}
constructor(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int
) : super(context, attrs, defStyleAttr) {
inflate()
}
fun addSubviews() {
val views = mutableListOf<View>()
repeat(2) { count ->
views.add(
TextView(context).apply {
text = "Test $count"
setBackgroundResource(R.drawable.rectangle_debug)
}
)
}
views.forEach {
addView(it)
}
flow.apply {
//setWrapMode(Flow.WRAP_CHAIN)
}
flow.referencedIds = views.map { it.id }.toIntArray()
post { requestLayout() }
}
private fun inflate() {
LayoutInflater.from(context).inflate(R.layout.widget_featured_relation, this)
}
}
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="<http://schemas.android.com/apk/res/android>"
xmlns:app="<http://schemas.android.com/apk/res-auto>">
<androidx.constraintlayout.helper.widget.Flow
android:id="@+id/flow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</merge>
I am totally missing something. Could someone explain to me why this custom view is rendered this way:ephemient
04/10/2021, 6:17 PMephemient
04/10/2021, 6:17 PM