Search code examples
androidcardview

How to increase and fit ImageView in CardView


I'm using some TextView and CardView in Recycle with android property: android:orientation="vertical", when I change layout_width and layout_height of ImageView, it doesn't change size of ImageView.

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:id="@+id/cardview1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    card_view:cardElevation="3dp"
    card_view:contentPadding="3dp"
    card_view:cardCornerRadius="3dp"
    card_view:cardMaxElevation="3dp"
    card_view:cardUseCompatPadding="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <com.android.volley.toolbox.NetworkImageView
            android:id="@+id/VollyNetworkImageView1"
            android:layout_width="250dp"
            android:layout_height="100dp"
            android:src="@mipmap/ic_launcher"
            android:gravity="top" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:id="@+id/textView_item"
            android:text="Image View"
            android:layout_centerVertical="true"
            android:layout_marginLeft="20dp"/>

      </LinearLayout>

</android.support.v7.widget.CardView>

I have tried a lot of ways but I have not got it yet, I wish it same with file photo attachment enter image description here

How to fix the problem ? Thank so much !


Solution

  • I think you just need to add the android:scaleType attribute to your ImageView.