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)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Android控件CardView實(shí)現(xiàn)卡片效果
- Android使用CardView實(shí)現(xiàn)圓角對話框
- 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提高之Android手機(jī)與BLE終端通信
這篇文章主要介紹了Android手機(jī)與BLE終端通信的方法,有很大的實(shí)用價(jià)值,需要的朋友可以參考下2014-08-08Android實(shí)現(xiàn)手機(jī)定位的案例代碼
今天小編就為大家分享一篇關(guān)于Android實(shí)現(xiàn)手機(jī)定位的案例代碼,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧2019-03-03如何判斷軟件程序是否聯(lián)網(wǎng) 聯(lián)網(wǎng)狀態(tài)提示信息Android實(shí)現(xiàn)
這篇文章主要為大家詳細(xì)介紹了如何判斷軟件程序是否聯(lián)網(wǎng)的實(shí)現(xiàn)代碼,Android實(shí)現(xiàn)聯(lián)網(wǎng)狀態(tài)信息提示,感興趣的小伙伴們可以參考一下2016-05-05Android自定義View實(shí)現(xiàn)雪花特效
這篇文章主要為大家詳細(xì)介紹了Android自定義View實(shí)現(xiàn)雪花特效,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2021-02-02android 9.0 launcher3 去掉抽屜式顯示所有 app(代碼詳解)
本文通過實(shí)例代碼給大家介紹了android 9.0 Launcher3 去掉抽屜式,顯示所有 app,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-11-11Android編程實(shí)現(xiàn)只顯示圖片一部分的方法
這篇文章主要介紹了Android編程實(shí)現(xiàn)只顯示圖片一部分的方法,涉及Android針對圖片的局部顯示操作技巧,需要的朋友可以參考下2016-10-10Android jni調(diào)試打印char陣列的實(shí)例詳解
這篇文章主要介紹了Android jni調(diào)試打印char陣列的實(shí)例詳解的相關(guān)資料,通過此文希望能幫助到大家實(shí)現(xiàn)這樣的功能,需要的朋友可以參考下2017-08-08