Primary Use of CardView and primary use of cardview
CardView
Released in the android sdk v7 support package. For details about how to add a project to the v7 package, refer to the portal here.
Card-based design is an important part of the brand-new Material style design. card-based design is suitable for displaying important information and using it as an item containing complex operations in the list.
CardView
Inherited fromFramelayout
, RatioFrameLayout
Three more important attributes are added,card_view:cardElevation
,card_view:cardCornerRadius
,card_view:cardBackgroundColor
.
card_view:cardElevation
, You can set the card shadow, you can makeCardView
There is an improved visual effect on the Z axis, which can give users a visual feeling of important information. Corresponding methods in the codepublic void setCardElevation (float radius)
.
card_view:cardCornerRadius
Obviously, it is setCardView
. Corresponding methods in the codepublic void setRadius (float radius)
.
card_view:cardBackgroundColor
, SetCardView
The background color. This attribute does not affect the shadow.card_view:cardElevation
. Corresponding methods in the codepublic void setCardBackgroundColor (int color)
.
<Android. support. v7.widget. cardViewandroid: id = "@ + id/cardview" android: layout_width = "fill_parent" android: layout_height = "wrap_content" card_view: cardElevation = "100dp" card_view: cardBackgroundColor = "@ color/gray" card_view: cardCornerRadius = "8dp" android: layout_marginLeft = "@ dimen/margin" android: layout_marginRight = "@ dimen/margin"> <TextView android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_margin = "@ dimen/margin" android: text = "here is CardView"/> </android. support. v7.widget. cardView>
Here is a sample officially provided by Android!
-------------
I have been working overtime since November 19 and spent a lot of time on the development of our end-to-end version. During this period, I planned several blog posts that I would like to write and I will release them soon, this article mainly introduces the use of new controls and how to design material styles compatible with versions earlier than lollipop, the material style design will also be a brand new android design in the first quarter of the 15-year project team.
(Reprinted please indicate the source: http://kennethyo.farbox.com/post/android/2014-12-28)