Using Firebase to store images and bring on Android screen

0
Well, I created a RecyclerView with CardView to show some photos that are stored in Firebase, but when I bring the photos to the screen it does not fit into the cardView so I left the image as android: layout_width="match_parent" android: layout_height="match_parent", I want the image to take up all the space I have reserved for it in cardView, could anyone help me?

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>

In-app return image

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);

        }
    
asked by anonymous 31.08.2018 / 14:36

1 answer

0

Solved!

I inserted the following line in the Adapter class in the onBindViewHolder method in my case I use Glide .centerCrop ()

Ex: 'public void onBindViewHolder (MyViewHolder holder, int position) {         final Item item = cardList.get (position);         holder.title.setText (item.getTitle ());         holder.description.setText (item.getDescription ());

    Glide.with(context)
            .load(item.getImage())
            .centerCrop()
            .into(holder.imageView);
}'
    
31.08.2018 / 19:02