CardView Layout
<?xml version="1.0" encoding="utf-8"?>
<ImageView
android:id="@+id/imageId"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<LinearLayout
android:orientation="vertical"
android:layout_margin="8dp"
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/titleId"
android:text="@string/title"
android:textSize="18sp"
android:textColor="@color/text"
android:textStyle="bold"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/subTitleId"
android:text="@string/subtitle"
android:textColor="@color/text"
android:textSize="14sp"
android:layout_marginTop="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
MyMainActivity,IshowonlytheFirebasecall.
privatevoidprepareCard(){databaseReference=firebaseDatabase.getReference("Data");
databaseReference.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
Item data = dataSnapshot.getValue(Item.class);
cardList.add(data);
recyclerView.setAdapter(mAdapter);
}