學(xué)習(xí)使用Material Design控件(三)使用CardView實(shí)現(xiàn)卡片效果
本文主要介紹CardView的使用,CardView是繼承自FrameLayout,使用比較簡(jiǎn)單,只需要用CardView包含其他View就可以實(shí)現(xiàn)卡片效果了。
實(shí)現(xiàn)效果如下:
加入依賴庫(kù)
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
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- 學(xué)習(xí)使用Material Design控件(二)使用DrawerLayout實(shí)現(xiàn)側(cè)滑菜單欄效果
- 學(xué)習(xí)使用Material Design控件(一)
- 微信小程序之MaterialDesign--input組件詳解
- Material Design系列之Behavior實(shí)現(xiàn)Android知乎首頁(yè)
- 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)題欄自動(dòng)縮放、放大效果
相關(guān)文章
android 中 SQLiteOpenHelper的封裝使用詳解
這篇文章主要介紹了android 中 SQLiteOpenHelper的封裝使用詳解,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-02-02Android帶進(jìn)度條的文件上傳示例(使用AsyncTask異步任務(wù))
這篇文章主要介紹了Android帶進(jìn)度條的文件上傳示例(使用AsyncTask異步任務(wù)),使用起來(lái)比較方便,將幾個(gè)方法實(shí)現(xiàn)就行,感興趣的小伙伴們可以參考一下。2016-11-11Android9.0 SystemUI 網(wǎng)絡(luò)信號(hào)欄定制修改的流程解析
這篇文章主要介紹了Android9.0 SystemUI 網(wǎng)絡(luò)信號(hào)欄定制修改的流程,本文通過(guò)圖文實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-11-11Android自定義圓形View實(shí)現(xiàn)小球跟隨手指移動(dòng)效果
這篇文章主要為大家詳細(xì)介紹了Android自定義圓形View實(shí)現(xiàn)小球跟隨手指移動(dòng)效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-03-03Android自定義View實(shí)現(xiàn)鐘擺效果進(jìn)度條PendulumView
這篇文章主要介紹了Android自定義View實(shí)現(xiàn)鐘擺效果進(jìn)度條PendulumView,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-09-09Android 自定義圖片地圖坐標(biāo)功能的實(shí)現(xiàn)
最近項(xiàng)目要求實(shí)現(xiàn)一個(gè)在自定義地圖圖片上添加坐標(biāo)信息的功能,類似于在圖片做標(biāo)注的功能,這種功能糾結(jié)該如何實(shí)現(xiàn)呢?下面小編通過(guò)實(shí)例代碼給大家介紹Android 自定義地圖的實(shí)現(xiàn),需要的朋友參考下吧2021-07-07Android App中實(shí)現(xiàn)可以雙擊放大和縮小圖片功能的實(shí)例
這篇文章主要介紹了Android App中實(shí)現(xiàn)可以雙擊放大和縮小圖片功能的實(shí)例,文中的例子不能做到逐級(jí)放大但可以做到邊界控制和以觸摸點(diǎn)為中心進(jìn)行放大,需要的朋友可以參考下2016-03-03Android實(shí)戰(zhàn)打飛機(jī)游戲之子彈生成與碰撞以及爆炸效果(5)
這篇文章主要為大家詳細(xì)介紹了Android實(shí)戰(zhàn)打飛機(jī)游戲之子彈生成與碰撞以及爆炸效果,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-07-07