I tried to inflate this constrains layout into another constrains layout.
but when I run it i got only get the pink card the four ImageView doesn't appear inside the card .
here is the main XML file which I need to inflate another layout inside it.
<?xml version="1.0" encoding="utf-8"?>
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/wall"
tools:context=".StepThreeActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout2"
android:layout_width="374dp"
android:layout_height="635dp"
android:background="@drawable/card"
android:backgroundTint="@color/white"
android:elevation="@dimen/cardview_default_elevation"
android:padding="13dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginBottom="11dp"
android:backgroundTint="@color/Blue"
android:clickable="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:srcCompat="@drawable/back" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/forward"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="11dp"
android:backgroundTint="@color/Blue"
android:clickable="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:srcCompat="@drawable/forward" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
here is java class related to the previous main XML
public class StepThreeActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_step_three);
initialization();
characterInitialization();
LayoutInflater inflater =
(LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
inflater.inflate(R.layout.card1,
constraintLayout, true);
}
here is card1.xml code
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout2c"
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:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="347dp"
android:layout_height="366dp"
android:layout_marginTop="16dp"
android:background="@drawable/card"
android:backgroundTint="#FBD5D8"
android:elevation="@dimen/cardview_default_elevation"
android:padding="13dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imageView1"
android:layout_width="111dp"
android:layout_height="149dp"
android:layout_marginStart="40dp"
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@mipmap/a1" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="106dp"
android:layout_height="150dp"
android:layout_marginStart="172dp"
android:layout_marginTop="168dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@mipmap/a2" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="112dp"
android:layout_height="152dp"
android:layout_marginStart="40dp"
android:layout_marginTop="164dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@mipmap/a3" />
<ImageView
android:id="@+id/imageView4"
android:layout_width="115dp"
android:layout_height="153dp"
android:layout_marginStart="172dp"
android:layout_marginTop="16dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@mipmap/a4" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>