0

I am using recyclerview to list items from sql, I have issues with the background color of item rows... I have tried changing it and nothing happens.

Here is my row layout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:background="@color/bg_main"
    android:layout_height="wrap_content">

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    <LinearLayout
        android:padding="10dp"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <de.hdodenhof.circleimageview.CircleImageView
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:src="@drawable/default_avatar"/>

        <RelativeLayout
            android:padding="10dip"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

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

            <TextView
                android:textSize="18sp"
                android:textColor="@color/text_color_black"
                android:id="@+id/opponentsName"
                android:text="Roger Nkosi"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

            <TextView
                android:layout_marginTop="5dp"
                android:textSize="14sp"
                android:textColor="@color/brownish_gray"
                android:id="@+id/callStatus"
                android:text="Roger Nkosi"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
            </LinearLayout>

            <TextView
                android:id="@+id/dateCallMade"
                android:layout_alignParentRight="true"
                android:text="14:00"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />

        </RelativeLayout>

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

</LinearLayout>

and here is my fragment's layout

<android.support.v4.widget.SwipeRefreshLayout 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"
    android:background="@color/bg_main"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    tools:context=".view.fragments.PrivateVoiceCallsDialogFragment">


   <!-- A RecyclerView with some commonly used attributes -->
   <android.support.v7.widget.RecyclerView
       android:scrollbars="vertical"
       android:id="@+id/voice_recycler_view"
       android:layout_height="match_parent"
       android:layout_width="match_parent" />

</android.support.v4.widget.SwipeRefreshLayout>

*bg_main is a simple white color with or without it the row items are dark...

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Roger Nkosi
  • 77
  • 12

2 Answers2

0

In your cardView component use cardBackgroundColor attribute, it will do the desired thing.

Ashwani
  • 1,294
  • 1
  • 11
  • 24
0

I think the CardView overlaps your parent linearLayout and thus you cannot see the the colour. Use cardBackgroundColor property on CardView or change background colour of its child linearLayout