Android Development Card View component CardView usages

Source: Internet
Author: User

The

CardView is a component in the Support library V7 package, which speaks about the simple use of cardview.

<span style= "FONT-SIZE:14PX;" ><android.support.v7.widget.cardview xmlns:android= "Http://schemas.android.com/apk/res/android"
       xmlns:card_view= "Http://schemas.android.com/apk/res-auto"        android:layout_width= "Match_parent"        android:layout_ height= "Match_parent"        android:layout_margin= "5DP"         card_view:cardbackgroundcolor= "@color/cardview_dark_background"         card_view:cardcornerradius= "5DP"  >          < relativelayout           android:layout_width= "Match_parent"            android:layout_height= "100DP"             android:padding= "5DP"  >      &NBsp;       <imageview                android:id= "@+id/pic"                 android:layout_width= "Match_parent"                 android:layout_height= "Match_parent"      
          android:layout_centerinparent= "true"                android:scaletype= "CenterCrop"  / >              <TextView                android:clickable= "true"                 android:id= "@+id/name"          &nbSp;      android:layout_width= "Match_parent"                 android:layout_height= "Match_parent"      
          android:layout_marginbottom= "10DP"                android:layout_marginright= "10DP"                android:gravity= "right| Bottom "               android:textcolor=" @android: Color/white "               
Android:textsize= "24SP"  />       </RelativeLayout>      </android.support.v7.widget.CardView> </span>

The


probably sees that it also wraps the original entry layout with the CardView control, and the width still uses the Fill parent form

Layout_margin to represent the spacing between cards, which should be half the real interval (cause you should know)

Cardcornerradius represents the radian of the perimeter of a card.

Cardbackgroundcolor represents the card background color

The latter two attributes belong to the Card_view namespace. So don't forget to add this name control in use



Android-cardview Simple Use (ii)

Ardview is more than 5.0 version of the control, is a card layout, inherited Framlayout, but can use Compatibility Pack old compatible with more than 4.0 of the device. The

Test environment is Android studio

1. Join dependencies:

Compile ' com.android.support:cardview-v7:21.0.3 '

2. Write layout:

<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/card_view"       android:layout_width= "match_parent"     
  android:layout_height= "wrap_content"       app:cardcornerradius= "4DP"  
    app:cardbackgroundcolor= "@color/style_color_primary" >           <LinearLayout          android:layout_ Width= "match_parent"           android:layout_height= "Wrap_content" >           <TextView               android:layout_width= "Wrap_content"                android:layout_height= "Wrap_content"                android:text= "hello cardview!" />       </LinearLayout>       </ Android.support.v7.widget.cardview>


Note: Here are two properties Cardcornerradius and Cardbackgroundcolor, which have been basically known for their meaning, the first is the fillet radius, and the second is the background color. The

also has a elevator property, but it is only possible to display the effect in more than 5.0 versions.

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.