總結一下 Material Design控制項 cradview 的用法,designcradview

來源:互聯網
上載者:User

總結一下 Material Design控制項 cradview 的用法,designcradview
本文主要介紹CardView的使用,CardView是繼承自FrameLayout,

使用比較簡單,只需要用CardView包含其他View就可以實現卡片效果了。


加入依賴庫 

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

在布局中使用

<?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/cardview_default_radius"        app:cardMaxElevation="@dimen/cardview_default_elevation"        >        <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="好多東西"                android:textColor="@android:color/holo_green_dark" />        </LinearLayout>    </android.support.v7.widget.CardView></LinearLayout>

其中 

  • app:cardBackgroundColor 設定CardView背景顏色
  • app:cardCornerRadius 設定CardView圓角大小
  • app:cardElevation 設定CardView陰影高度


運行效果:





著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.