0

I am very new to Android. I am trying to resize my cardview but it has no effect and reverts to its previous size. Can any one help me ?

Here is my cardview and Recyclerview code.

Recyclerview

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="1dp"
    android:paddingBottom="3dp"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/fragment_primary" tools:context=".Primary">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/list"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clipToPadding="false"
        android:paddingBottom="3dp"
        android:paddingLeft="3dp"
        android:paddingRight="3dp"
        android:paddingTop="2dp" />
</RelativeLayout>

cardview layout

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/card_view"
    android:layout_width="wrap_content"
    android:layout_height="360dp"
    android:layout_margin="8dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <ImageView
            android:id="@+id/row_image"
            android:layout_width="fill_parent"
            android:layout_height="250dp"
            android:layout_alignParentTop="true"
            android:scaleType="centerCrop"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true" />
        <TextView
            android:id="@+id/row_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/row_image"
            android:maxLines="3"
            android:padding="8dp"
            android:textColor="#222"
            android:textStyle="bold"
            android:textSize="22dp" />
        <TextView
            android:id="@+id/row_description"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/row_title"
            android:maxLines="3"
            android:padding="8dp"
            android:textColor="#666"
            android:textSize="14dp" />
    </RelativeLayout>
</android.support.v7.widget.CardView>
APC
  • 144,005
  • 19
  • 170
  • 281
vishnu
  • 87
  • 8

1 Answers1

0

If you want to resize full CardView i think you need to change these lines:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

Nowadays, you only changed height of the image:

    android:layout_height="250dp"

Read also this: What's the difference between fill_parent and wrap_content?

EDIT: Delete paddings in RecyclerView - the take some space.

If have more question, please free to ask

Community
  • 1
  • 1
piotrek1543
  • 19,130
  • 7
  • 81
  • 94