Questions tagged [android-cardview]

CardView is a widget used to show complex lists and cards in your app, it has material design style by default.

CardView is a widget used to show complex lists and cards in your app, it has material design style by default. CardView extends the FrameLayout class and lets you show information inside cards that have a consistent look on any app. CardView widgets can have shadows and rounded corners.

Useful links

2320 questions
341
votes
26 answers

RecyclerView inside ScrollView is not working

I'm trying to implement a layout which contains RecyclerView and ScrollView at the same layout. Layout template: ... …
246
votes
14 answers

Ripple effect on Android Lollipop CardView

I'm trying to get a CardView to display the ripple effect when touched by setting the android:backgound attribute in the activity XML file as described here on the Android Developers page, but it isn't working. No animation at all, but the method in…
191
votes
9 answers

CardView background color always white

I use RecyclerView with GridLayoutManager and have each item as CardView. Unfortunately, the CardView here does not seem to change its background color. I tried in layout and programmatically as well but I have tried nothing seems to work. I have…
Ishaan
  • 3,658
  • 2
  • 23
  • 39
159
votes
27 answers

Change the background color of CardView programmatically

The CardView has an attribute card_view:cardBackgroundColor to define the background color. This attribute works fine. At the same time there isn't a method to change the color dynamically. I've just tried solutions…
Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
143
votes
21 answers

CardView not showing Shadow in Android L

My Cardview inside Listview is not showing shadow in Android L(Nexus 5). Also the round edges are not properly shown. Here is the code for Listview's Adapter View :
132
votes
10 answers

CardView layout_width="match_parent" does not match parent RecyclerView width

I have a fragment with contains a RecyclerView with layout_width="match_parent":
129
votes
17 answers

CardView Corner Radius

Is there a way to make CardView only have corner radius at the top?
terencey
  • 3,282
  • 4
  • 32
  • 40
120
votes
9 answers

How to add colored border on cardview?

I am new to Android and this is my first question here. I am trying to add a colored vertical border at the beginning of the cardview. How can I achieve it on xml ? I tried adding it with empty textview but it is messing up the whole cardview…
George Forster
  • 1,201
  • 2
  • 9
  • 5
113
votes
9 answers

Programmatically set '?selectableItemBackground' on Android view

In xml, I often do this to emulate onClick effect:
Hendra Anggrian
  • 5,780
  • 13
  • 57
  • 97
108
votes
8 answers

Transparent background on CardView - Android

I want to do transparent background on CardView. I know backgroundColor but i have image on my Layout. Do you know how do it? Or something which work as cardview but i will set a transparent background? Regards
mac229
  • 4,319
  • 5
  • 18
  • 24
107
votes
13 answers

How to disable the shadow around card view in android

I am working on demo application in which I am using the card view of the support library. By default, it is adding a shadow around it. I want to remove this shadow & should looks like simple. I tried this (not working for me): CardView cardView =…
N Sharma
  • 33,489
  • 95
  • 256
  • 444
101
votes
6 answers

Setting Elevation in XML on AppCompat CardView on Android 5.0

From what I understand, early in the preview stage there seemed to be no way to set elevation in XML only on CardViews without a hack in Java. Now that the official release is out, is there any way of doing this in XML without writing Java code to…
99
votes
16 answers

How to know when the RecyclerView has finished laying down the items?

I have a RecyclerView that is inside a CardView. The CardView has a height of 500dp, but I want to shorten this height if the RecyclerView is smaller. So I wonder if there is any listener that is called when the RecyclerView has finished laying down…
wm1sr
  • 1,905
  • 1
  • 16
  • 20
88
votes
14 answers

Round only top corner of cardview

I want to corner only the top of a cardview. I used below property and it is rounding all the corner. I want to show an overlap of all cards card_view:cardCornerRadius="4dp" here is my layout
Puneet Kushwah
  • 1,495
  • 2
  • 17
  • 35
82
votes
5 answers

How to set the padding for CardView widget in Android L

I'm using android:paddingLeft and android:paddingTop to set the padding for the new CardView widget but it doesn't work. I can set the margin for all the controls inside the CardView as a workaround but that's a pain if there are too many controls.…
nomongo
  • 3,435
  • 7
  • 30
  • 33
1
2 3
99 100