Android MaterialCardView的使用介紹與示例
Android—MaterialCardView的使用

我們的征程是星辰大海,而非人間煙塵
文章目錄 Android---MaterialCardView的使用演示xml布局其他的屬性
演示

xml布局
<com.google.android.material.card.MaterialCardView
android:id="@+id/materialCardView2"
android:layout_width="170dp"
android:layout_height="170dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:clickable="true" // 是否可點(diǎn)擊
app:cardCornerRadius="20dp" // 圓角半徑
app:cardElevation="20dp" // 陰影范圍
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/banner"
app:rippleColor="#A8C0EC" // 點(diǎn)擊陰影特效的顏色
app:state_dragged="true">
<ImageView
android:layout_width="match_parent"
android:layout_height="140dp"
android:scaleType="centerCrop"
android:src="@drawable/quesans" />
<TextView
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:layout_marginTop="140dp"
android:text="問答"
android:textColor="@color/black"
android:textFontWeight="@android:integer/config_mediumAnimTime"
android:textSize="18sp" />
</com.google.android.material.card.MaterialCardView>

其他的屬性
| 特征 | 相關(guān)屬性 |
|---|---|
| Border | app:strokeColor app:strokeWidth |
| Checkable | android:checkable |
| Checked Icon | app:checkedIcon app:checkedIconTint |
| Foreground Color | app:cardForegroundColor |
| Ripple Color | app:rippleColor |
當(dāng)然你還可以在Java/Kotlin代碼中使用一些方法:
void setCheckable (boolean checkable)//設(shè)置是否可以選擇 void setChecked (boolean checked)//選中的狀態(tài) void setCheckedIcon (Drawable checkedIcon)//選中圖標(biāo)的樣式 void setCheckedIconResource (int id)//選中圖標(biāo)的樣式 void setDragged (boolean dragged)//是否可拖動(dòng) void setRippleColor (ColorStateList rippleColor)//波紋效果的顏色 void setStrokeColor (int strokeColor)//卡片邊的顏色 void setStrokeWidth (int strokeWidth)//卡片邊的寬帶 void toggle ()//控制checkable的開關(guān)
到此這篇關(guān)于Android MaterialCardView的使用介紹與示例 的文章就介紹到這了,更多相關(guān)Android MaterialCardView內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Android控件CardView實(shí)現(xiàn)卡片效果
- Android使用CardView實(shí)現(xiàn)圓角對(duì)話框
- Android控件CardView實(shí)現(xiàn)卡片布局
- Android CardView+ViewPager實(shí)現(xiàn)ViewPager翻頁動(dòng)畫的方法
- Android使用CardView作為RecyclerView的Item并實(shí)現(xiàn)拖拽和左滑刪除
- Android CardView詳解及使用方法和實(shí)例
- Android中使用CircleImageView和Cardview制作圓形頭像的方法
- Android應(yīng)用開發(fā)中CardView的初步使用指南
相關(guān)文章
Android把Bitmap保存為PNG圖像文件的簡(jiǎn)單代碼
這篇文章主要介紹了Android把Bitmap保存為PNG圖像文件的方法,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-08-08
如何獲取Android設(shè)備掛載的所有存儲(chǔ)器
這篇文章主要為大家詳細(xì)介紹了如何獲取Android設(shè)備掛載的所有存儲(chǔ)器,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-04-04
Android實(shí)現(xiàn)代碼畫虛線邊框背景效果
可能之前遇到這樣的需求大家都會(huì)想到用圖片背景來解決,下面這篇文章將給大家介紹Android如何利用代碼畫虛線邊框背景的效果,有需要的朋友們可以參考借鑒,下面來跟著小編一起學(xué)習(xí)學(xué)習(xí)吧。2016-12-12
android創(chuàng)建數(shù)據(jù)庫(SQLite)保存圖片示例
這篇文章主要介紹了android創(chuàng)建數(shù)據(jù)庫,保存圖片到數(shù)據(jù)庫再從數(shù)據(jù)庫取圖片的方法,大家參考使用吧2014-01-01
Android中默認(rèn)系統(tǒng)的聲音/大小修改和配置詳解
這篇文章主要給大家介紹了關(guān)于Android中默認(rèn)系統(tǒng)的聲音/大小修改和配置的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)各位Android開發(fā)者們具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起看看吧。2017-11-11
Android 混合動(dòng)畫詳解及實(shí)現(xiàn)代碼
這篇文章主要介紹了Android 混合動(dòng)畫詳解及實(shí)現(xiàn)代碼的相關(guān)資料,簡(jiǎn)單的一種動(dòng)畫(如旋轉(zhuǎn)、縮放、漸變、位移等)有時(shí)候并不能滿足我們項(xiàng)目的要求,這時(shí)候就需要運(yùn)用到混合動(dòng)畫,需要的朋友可以參考下2016-11-11
Android中@id和@+id及@android:id的區(qū)別介紹
這篇文章主要給大家介紹了關(guān)于Android中@id和@+id及@android:id的區(qū)別的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-09-09

