title: CardView not showing inside fragment
body: <p>I am a novice Java/Android studio student, just blindly following examples on the internet.
  I wanted to make a CardView inside a fragment, but most of the examples out there were putting cardview inside an activity, so I searched and changed the appropriate codes. After some time tinkering, I managed to make it build without errors.
  However, cardview is not showing up in RecyclerView.
  I suspect it is a layout issue, but after all the changes with layout_height and layout_width, I can't get cardview to be seen.
  Any help will be appreciated.</p>
  <p>My code:</p>
  <p><strong>HomeFragment.java</strong></p>
  <pre><code>public class HomeFragment extends Fragment implements View.OnClickListener {
  
  final int ITEM_SIZE = 5;
  
  public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
      View v = inflater.inflate(R.layout.fragment_home, container, false);
      Button bh = v.findViewById(R.id.bh);
      bh.setOnClickListener(this);
  
      RecyclerView rv = (RecyclerView) v.findViewById(R.id.recyclerview);
      LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity());
      rv.setHasFixedSize(true);
      rv.setLayoutManager(layoutManager);
  
      List&lt;Item&gt; items = new ArrayList&lt;&gt;();
      Item[] item = new Item[ITEM_SIZE];
      item[0] = new Item(R.drawable.a, &quot;#1&quot;);
      item[1] = new Item(R.drawable.b, &quot;#2&quot;);
      item[2] = new Item(R.drawable.c, &quot;#3&quot;);
      item[3] = new Item(R.drawable.d, &quot;#4&quot;);
      item[4] = new Item(R.drawable.e, &quot;#5&quot;);
  
      RecyclerAdapter adaptor = new RecyclerAdapter(getActivity(), items, R.layout.fragment_home);
      rv.setAdapter(adaptor);
      return v;
  }
  
  @Override
  public void onClick(View v) {
      switch (v.getId()) {
          case R.id.bh:
              ((BottomNavigationView)getActivity().findViewById(R.id.nav_view)).setSelectedItemId(R.id.navigation_settings);
              break;
      }
  }
  </code></pre>
  <p>}</p>
  <hr />
  <p><strong>RecyclerAdapter.java</strong></p>
  <pre><code>public class RecyclerAdapter extends RecyclerView.Adapter&lt;RecyclerAdapter.ViewHolder&gt; {
  Context context;
  List&lt;Item&gt; items;
  int item_layout;
  
  public RecyclerAdapter(Context context, List&lt;Item&gt; items, int item_layout) {
      this.context = context;
      this.items = items;
      this.item_layout = item_layout;
  }
  
  @Override
  public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.fragment_home, null);
      return new ViewHolder(v);
  }
  
  @Override
  public void onBindViewHolder(ViewHolder holder, int position) {
      final Item item = items.get(position);
      Drawable drawable = ContextCompat.getDrawable(context, item.getImage());
      holder.image.setBackground(drawable);
      holder.title2.setText(item.getTitle());
      holder.cardview.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Toast.makeText(context, item.getTitle(), Toast.LENGTH_SHORT).show();
          }
      });
  }
  
  @Override
  public int getItemCount() {
      return this.items.size();
  }
  
  public class ViewHolder extends RecyclerView.ViewHolder {
      ImageView image;
      TextView title2;
      CardView cardview;
  
      public ViewHolder(View itemView) {
          super(itemView);
          image = (ImageView) itemView.findViewById(R.id.image);
          title2 = (TextView) itemView.findViewById(R.id.title2);
          cardview = (CardView) itemView.findViewById(R.id.cardview);
      }
  }
  </code></pre>
  <p>}</p>
  <hr />
  <p><strong>Item.java</strong></p>
  <pre><code>public class Item {
  int image;
  String title;
  
  int getImage() { return this.image; }
  String getTitle() { return this.title; }
  
  public Item(int image, String title) {
      this.image = image;
      this.title = title;
  }
  </code></pre>
  <p>}</p>
  <hr />
  <p><strong>fragment_home.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;androidx.constraintlayout.widget.ConstraintLayout 
  xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
  xmlns:tools=&quot;http://schemas.android.com/tools&quot;
  android:id=&quot;@+id/MainLayout&quot;
  android:layout_width=&quot;match_parent&quot;
  android:layout_height=&quot;match_parent&quot;&gt;
  
  &lt;TextView
      android:id=&quot;@+id/text_home&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:text=&quot;@string/title_home&quot;
      android:textSize=&quot;40sp&quot;
      android:textStyle=&quot;bold&quot;
      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
      app:layout_constraintHorizontal_bias=&quot;0.952&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot;
      app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  
  &lt;androidx.recyclerview.widget.RecyclerView
      android:id=&quot;@+id/recyclerview&quot;
      android:layout_width=&quot;0dp&quot;
      android:layout_height=&quot;wrap_content&quot;
      app:layout_constraintBottom_toTopOf=&quot;@+id/bh&quot;
      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot;
      app:layout_constraintTop_toBottomOf=&quot;@+id/text_home&quot; /&gt;
  
  &lt;Button
      android:id=&quot;@+id/bh&quot;
      android:layout_width=&quot;wrap_content&quot;
      android:layout_height=&quot;wrap_content&quot;
      android:layout_marginBottom=&quot;50dp&quot;
      android:text=&quot;@string/title_settings&quot;
      app:layout_constraintBottom_toBottomOf=&quot;parent&quot;
      app:layout_constraintEnd_toEndOf=&quot;parent&quot;
      app:layout_constraintStart_toStartOf=&quot;parent&quot; /&gt;
  </code></pre>
  <p>&lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;</p>
  <hr />
  <p><strong>card.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  xmlns:app=&quot;http://schemas.android.com/apk/res-auto&quot;
  android:layout_width=&quot;match_parent&quot;
  android:layout_height=&quot;match_parent&quot;
  android:orientation=&quot;vertical&quot;&gt;
  
  &lt;com.google.android.material.card.MaterialCardView
      android:id=&quot;@+id/cardview&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;200dp&quot;
      android:clickable=&quot;true&quot;
      android:focusable=&quot;true&quot;
      android:foreground=&quot;?android:attr/selectableItemBackground&quot;
      app:cardCornerRadius=&quot;20dp&quot;
      app:cardElevation=&quot;4dp&quot;&gt;
  
      &lt;LinearLayout
          android:layout_width=&quot;match_parent&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:orientation=&quot;vertical&quot;&gt;
  
          &lt;ImageView
              android:id=&quot;@+id/image&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;150dp&quot;
              android:scaleType=&quot;centerCrop&quot; /&gt;
  
          &lt;TextView
              android:id=&quot;@+id/title2&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;50dp&quot;
              android:layout_margin=&quot;5dp&quot;
              android:text=&quot;TextView&quot;
              android:textSize=&quot;25sp&quot; /&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/com.google.android.material.card.MaterialCardView&gt;
  </code></pre>