學(xué)習(xí)使用Material Design控件(三)使用CardView實(shí)現(xiàn)卡片效果
本文主要介紹CardView的使用,CardView是繼承自FrameLayout,使用比較簡單,只需要用CardView包含其他View就可以實(shí)現(xiàn)卡片效果了。
實(shí)現(xiàn)效果如下:

加入依賴庫
dependencies {
….
compile 'com.android.support:cardview-v7:22.2.0'
}
Layout布局
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="10dp"
app:cardElevation="10dp"
android:layout_marginBottom="@dimen/card_margin"
android:layout_marginLeft="@dimen/card_margin"
android:layout_marginRight="@dimen/card_margin">
<LinearLayout
style="@style/CardView.Content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/book1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/book_title_1"
android:textAppearance="@style/TextAppearance.AppCompat.Title"
android:textColor="@color/primary_text" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="@string/book_description_1"
android:textColor="@color/secondary_text" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
app:cardBackgroundColor 設(shè)置CardView背景顏色
app:cardCornerRadius 設(shè)置CardView圓角大小
app:cardElevation 設(shè)置CardView陰影高度
項(xiàng)目源碼已發(fā)布到Github,以后慢慢加入其他控件的使用。
源碼地址:MaterialDesignExample
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 學(xué)習(xí)使用Material Design控件(二)使用DrawerLayout實(shí)現(xiàn)側(cè)滑菜單欄效果
- 學(xué)習(xí)使用Material Design控件(一)
- 微信小程序之MaterialDesign--input組件詳解
- Material Design系列之Behavior實(shí)現(xiàn)Android知乎首頁
- Material Design系列之Behavior上滑顯示返回頂部按鈕
- Material Design系列之Behavior實(shí)現(xiàn)支付密碼彈窗和商品屬性選擇效果
- Material Design系列之自定義Behavior支持所有View
- Android5.0中Material Design的新特性
- Android App仿QQ制作Material Design風(fēng)格沉浸式狀態(tài)欄
- 學(xué)習(xí)使用Material Design控件(四)Android實(shí)現(xiàn)標(biāo)題欄自動縮放、放大效果
相關(guān)文章
android實(shí)現(xiàn)點(diǎn)擊圖片全屏展示效果
這篇文章主要為大家詳細(xì)介紹了android實(shí)現(xiàn)點(diǎn)擊圖片全屏展示效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-08-08
Android Studio 視頻播放失敗 start called in state1 異常怎么解決
很多朋友問小編在使用MediaPlayer播放音頻時(shí)報(bào)出 E/MediaPlayerNative: start called in state 1, mPlayer(0x0)問題,該如何處理呢,今天小編給大家?guī)砹薃ndroid Studio 視頻播放失敗 start called in state1 異常問題,需要的朋友可以參考下2020-03-03
詳談Matrix中preTranslate()和postTranslate()的理解
這篇文章主要為大家詳細(xì)介紹了Matrix中preTranslate()和postTranslate()的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-11-11
Android檢測手機(jī)多點(diǎn)觸摸點(diǎn)數(shù)的方法
這篇文章主要為大家詳細(xì)介紹了Android檢測手機(jī)多點(diǎn)觸摸點(diǎn)數(shù)的方法,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-05-05
Android開發(fā)中簡單設(shè)置啟動界面的方法
這篇文章主要介紹了Android開發(fā)中簡單設(shè)置啟動界面的方法,涉及Android界面布局、加載、跳轉(zhuǎn)等相關(guān)操作技巧,需要的朋友可以參考下2018-01-01
Android 中從屏幕左下角彈出Dialog動畫效果的實(shí)現(xiàn)代碼
這篇文章主要介紹了Android 中從屏幕左下角彈出Dialog動畫效果的實(shí)現(xiàn)代碼,非常不錯,具有參考借鑒價(jià)值,需要的朋友可以參考下2016-12-12
Android2.3實(shí)現(xiàn)Android4.0風(fēng)格EditText的方法
這篇文章主要介紹了Android2.3實(shí)現(xiàn)Android4.0風(fēng)格EditText的方法,涉及Android界面布局及控件調(diào)用的相關(guān)技巧,需要的朋友可以參考下2016-03-03
Android Studio修改Log信息顏色的實(shí)現(xiàn)
這篇文章主要介紹了Android Studio修改Log信息顏色的實(shí)現(xiàn),具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-04-04

