Material Design(三)--UI控件之CardView

CardView繼承自FrameLayout,容許你在card視圖中顯示信息. CardView也能夠設置陰影和圓角。(其實如今不少應用都自定義了Card視圖,Google這回將card視圖做爲基本控件,能夠拿來直接使用了)html

Layout中爲CardView設置圓角使用card_view:cardCornerRadius屬性android

代碼中爲CardView設置圓角使用CardView.setRadius方法佈局

爲CardView設置背景顏色使用card_view:cardBackgroundColor屬性spa

在佈局中包含一個CardView,以下:.net

<!-- A CardView that contains a TextView -->  
<android.support.v7.widget.CardView  
    xmlns:card_view="http://schemas.android.com/apk/res-auto"  
    android:id="@+id/card_view"  
    android:layout_gravity="center"  
    android:layout_width="200dp"  
    android:layout_height="200dp"  
    card_view:cardCornerRadius="4dp">  
  
    <TextView  
        android:id="@+id/info_text"  
        android:layout_width="match_parent"  
        android:layout_height="match_parent" />  
</android.support.v7.widget.CardView> 
兼容性:
 
RecyclerViewCardView都包含在Android L Developer Preview Support Library中,因此他們能夠在以前的版本中使用,只會有一些限制。
原文地址:http://www.open-open.com/lib/view/open1416664070023.html
詳細參考:http://blog.csdn.net/a396901990/article/details/40153759
相關文章
相關標籤/搜索