I using below XML to use placeholder.
but I can see only button1
, 'root_container3'
when use placeholder.
'root_container2' is not be placeholder because of MATCH_CONSTRAINT
android:id="@+id/button2"
android:layout_width="0dp" // MATCH_CONSTRAINT
android:layout_height="0dp" // MATCH_CONSTRAINT
I guess button2
was not measured with match_constraint
(If button has specific dimen value like button3
, it was worked but Match_constraint is not.)
I have no idea about this..
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layoutDescription="@xml/activity_main_scene"
tools:context=".MainActivity">
<androidx.constraintlayout.widget.Placeholder
android:id="@+id/place_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/root_container2"
android:layout_width="200dp"
android:layout_height="100dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
<Button
android:id="@+id/button2"
android:layout_width="0dp"
android:layout_height="0dp"
android:text="Button2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/root_container3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent">
<Button
android:id="@+id/button3"
android:layout_width="200dp"
android:layout_height="100dp"
android:text="Button3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
/
button1.setOnClickListener {
place_holder.setContentId(R.id.button1)
}
button2.setOnClickListener {
place_holder.setContentId(R.id.root_container2)
}
button3.setOnClickListener {
place_holder.setContentId(R.id.root_container3)
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…