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" // 是否可點擊
app:cardCornerRadius="20dp" // 圓角半徑
app:cardElevation="20dp" // 陰影范圍
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/banner"
app:rippleColor="#A8C0EC" // 點擊陰影特效的顏色
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 |
當然你還可以在Java/Kotlin代碼中使用一些方法:
void setCheckable (boolean checkable)//設(shè)置是否可以選擇 void setChecked (boolean checked)//選中的狀態(tài) void setCheckedIcon (Drawable checkedIcon)//選中圖標的樣式 void setCheckedIconResource (int id)//選中圖標的樣式 void setDragged (boolean dragged)//是否可拖動 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)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
如何判斷軟件程序是否聯(lián)網(wǎng) 聯(lián)網(wǎng)狀態(tài)提示信息Android實現(xiàn)
這篇文章主要為大家詳細介紹了如何判斷軟件程序是否聯(lián)網(wǎng)的實現(xiàn)代碼,Android實現(xiàn)聯(lián)網(wǎng)狀態(tài)信息提示,感興趣的小伙伴們可以參考一下2016-05-05
android 9.0 launcher3 去掉抽屜式顯示所有 app(代碼詳解)
本文通過實例代碼給大家介紹了android 9.0 Launcher3 去掉抽屜式,顯示所有 app,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-11-11
Android jni調(diào)試打印char陣列的實例詳解
這篇文章主要介紹了Android jni調(diào)試打印char陣列的實例詳解的相關(guān)資料,通過此文希望能幫助到大家實現(xiàn)這樣的功能,需要的朋友可以參考下2017-08-08

