Android CardView Detailed
Android5.0 introduces us to a completely new control –cardview, which, in essence, can be seen as framelayout adding rounded corners and shadow effects on top of itself. Please note that the CardView is packaged as a layout and is often used as a container in the item layout of ListView and Recyclerview.
Found a good-looking dongdong cardview, he in support V7 bag ~ ~
As the name suggests is the card view, you can set shadows, rounded corners, and so on.
Looks like this:
Or you can put it in the ListView:
How to use
Secondly, it introduces its basic properties:
App:cardbackgroundcolor This is setting the background color
App:cardcornerradius this is to set fillet size
App:cardelevation This is the shadow that sets the Z axis
App:cardmaxelevation This is the maximum height value of the z axis set
App:cardusecompatpadding whether to use compatpadding
App:cardpreventcorneroverlap whether to use Preventcorneroverlap
App:contentpadding Set the content padding
App:contentpaddingleft set the left padding of content
App:contentpaddingtop set content on padding
App:contentpaddingright set the right padding of the content
App:contentpaddingbottom set the bottom of the content padding
Add a CardView to the XML file
<android.support.v7.widget.cardview xmlns:card_view= "Http://schemas.android.com/apk/res-auto"
android: Layout_width= "200DP"
android:layout_height= "wrap_content"
<--! set CardView background color-->
Card_view: Cardbackgroundcolor= "#303069"
<--! set CardView radius-->
card_view:cardcornerradius= "10DP"
card_ View:cardpreventcorneroverlap= "true"
card_view:cardusecompatpadding= "true"
<--! setting CardView padding-- >
card_view:contentpadding= "10DP" >
<textview
android:text= "I am CardView"
android: Textcolor= "#fff"
android:layout_width= "wrap_content"
android:layout_height= "wrap_content"/>
</android.support.v7.widget.CardView>
Inside can wrap content, through observation source code we found that CardView is actually a framelayout, so use the same way as Framelayout
public class CardView extends Framelayout implements Cardviewdelegate {
}
Or you can also be used for listview~~ anyway very simple beautiful is AH ~ ~
In the future meet what fillet demand, you can use this to complete, and not what Porterduffxfermode ~ ~
Thank you for reading, I hope to help you, thank you for your support for this site!