Summarize the usage of the Material Design control cradview

Source: Internet
Author: User

Summarize the usage of the Material Design control cradview
This article mainly introduces the use of CardView. CardView inherits from FrameLayout,

It is easy to use. You only need to use CardView to include other views to achieve the card effect.


Add dependency Library

compile 'com.android.support:cardview-v7:22.2.0'

Use in Layout

<? Xml version = "1.0" encoding = "UTF-8"?> <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" xmlns: app = "http://schemas.android.com/apk/res-auto" android: layout_width = "match_parent" android: layout_height = "match_parent" android: orientation = "vertical"> <android. support. v7.widget. cardView android: layout_width = "match_parent" android: layout_height = "wrap_content" android: layout_marginTop = "10dp" app: cardElevation = "@ dimen/cardview_compat_inset_shadow" app: cardCornerRadius = "@ dimen/plugin" app: cardMaxElevation = "@ dimen/plugin"> <LinearLayout android: layout_width = "match_parent" android: layout_height = "wrap_content" android: orientation = "vertical" android: padding = "20dp"> <TextView android: id = "@ + id/textview1" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: layout_gravity = "center" android: text = "@ string/trytry" android: textColor = "@ android: color/holo_blue_dark" android: textSize = "25dp"/> <TextView android: id = "@ + id/desc" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_marginTop = "10dp" android: text = "many things" android: textColor = "@ android: color/holo_green_dark"/> </LinearLayout> </android. support. v7.widget. cardView> </LinearLayout>

Where

  • App: cardBackgroundColor sets the CardView background color
  • App: cardCornerRadius: Set the CardView rounded corner size
  • App: cardElevation sets the CardView shadow height


Running effect:





Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.