Before using CardView, be aware of what CardView is. CardView, like LinearLayout and Framelayout, are viewgroup, that is, containers for other controls. CardView inherits from Framelayout, so Framelayout has all the properties he has, while CardView has several special properties:
Above the API21 (Android L) level has the attribute elevation, meaning CardView z-axis shadow, only the L platform is valid. Can only be specified by the elevation attribute in XML;
The remaining (more than 2.0) has the attribute Cardbackgroundcolor, meaning CardView card color, can only be specified by the XML cardbackgroundcolor;
The remainder (2.0 or more) has the attribute Cardconerradius, which means the cardview of the rounded corners of the card, the unit dimen (DP px SP), which can be specified by XML or by Setradius in the code.
<android.support.v7.widget.cardview xmlns:android= "Http://schemas.android.com/apk/res/android" xmlns:app= "Http://schemas.android.com/apk/res-auto" android:id= "@+id/cardview" app:cardcornerradius= "8DP" app:cardbackgroundcolor= "@color/black" Android:layout_margin= "8DP" android:layout_height= "80DP" android:layout_width= "Match_parent" > < Textview android:text= "TextView in CardView " android:layout_gravity=" center android:textsize= "26SP" android:textColor= "@color/l_white" android:layout_width= "Wrap_ Content " android:layout_height=" wrap_content " /> </android.support.v7.widget.cardview>
It also mentions that CardView is like a fragmentlayout, so there is a hierarchy in his content, and we should pay attention to it. And in combination with Recyclerview, there will be a lot of unexpected effects yo
Android App Development: use of CardView