Android App Development: use of CardView

Source: Internet
Author: User

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

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.