Ansh yadav Ansh yadav - 1 year ago 138
Android Question

android:cardView width is not matching to it's parent

Please Read Full - Well I don't know what's gone wrong here.
Each of the

CardView
Bottom is not matching to it's parent.!

I'm trying to add background to
RecyclerView
and make transparent background to
CardView


custom_row Code -

<LinearLayout 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/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">

<android.support.v7.widget.CardView
android:id="@+id/cardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardCornerRadius="@dimen/card_album_radius">

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingBottom="7.5dp"
android:paddingTop="7.5dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="horizontal">

<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp">

<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/imageView1"
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"
android:src="@drawable/ic_action_movie" />

</RelativeLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:layout_weight="0.75"
android:orientation="vertical">

<TextView
android:id="@+id/playList_name"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="16dp"
android:ellipsize="end"
android:maxLines="1"
android:text="SongName"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Title"
android:textColor="#c1c1c1"
android:textSize="16sp" />

<TextView
android:id="@+id/album_artist"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:layout_below="@id/playList_name"
android:layout_marginLeft="16dp"
android:layout_weight="0.25"
android:ellipsize="end"
android:maxLines="1"
android:text="ARTIST"
android:textColor="#a1a1a1"
android:textIsSelectable="false"
android:textSize="12sp" />


</LinearLayout>

<ImageView
android:id="@+id/my_overflow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_weight="1.4"
android:paddingRight="16dp"
android:scaleType="fitEnd"
android:src="@drawable/ic_grade" />

</LinearLayout>

</RelativeLayout>

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


And here's song_fragment.xml -

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.ansh.albums.Fragments.Songs">

<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>




Here's the Result which i got -
image

I don't know why each of the cardView is not matching to it's parent width at bottom?

Please help.!

Answer Source

You can use try this to get ride of the bottom divider

<android.support.v7.widget.CardView
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/cv"
    card_view:cardElevation="0dp"
    card_view:cardMaxElevation="0dp"
    card_view:cardPreventCornerOverlap="false">