Extra padding at the top and bottom in CardView

advertisements

I'm using to recyclerview to display a list a images from a web service. I'm trying to display images in ImageView within CardView widget.Everything is working fine. All the images and lists are displaying properly. but when i try to run on Kitkat 4.4.4 its showing extra(Large) padding at top and bottom of image within the Cardview. I'm using ImageView only no text nothing.

Check the attached image.

on 4.4.4

on Lollipop

I've tried almost everything that i've found on SO so far. any help is appreciated. Thanks

XML code for Cardview

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_horizontal_margin_half">

<android.support.v7.widget.CardView
    android:layout_centerHorizontal="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/offwhite"
    android:id="@+id/cardlayout_malls"
    android:layout_marginLeft="@dimen/activity_horizontal_margin_half"
    card_view:cardUseCompatPadding="true"
    android:layout_marginRight="@dimen/activity_horizontal_margin_half">-->
    <!-- Thumbnail Image -->

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/bannerImageView"/>
    </android.support.v7.widget.CardView>
    </RelativeLayout>


try this way

card_view:cardPreventCornerOverlap="false"

OR

in imageview you can use add this in your imageview

 <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:id="@+id/bannerImageView"/>