I'm unable to inflate the ViewStub from a fragment. When I tried to inflate it from an Activity it works fine.
Here's my code: Dashboard.java
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_dashboard, container, false);
        infographics = view.findViewById(R.id.infographicStub);
        infographics.setLayoutResource(R.layout.dashboard_infographics);
        infographics.inflate();
        infographics.setVisibility(View.VISIBLE);
        return view;
fragment_dashboard.xml
<?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:id="@+id/dashboardLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorPrimary"
    android:paddingTop="20dp"
    tools:context=".dashboard.fragments.Dashboard">
    <ViewStub
        android:id="@+id/infographicStub"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inflatedId="@+id/subTree"
        android:layout="@layout/dashboard_infographics"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
    <LinearLayout
        android:id="@+id/lightContainer"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/style_light_container"
        android:backgroundTint="@color/colorSecondary"
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/infographicStub">
        <include layout="@layout/dashboard_wallet_option" />
    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Can anyone tell me what I'm doing wrong? Thanks in advance