當前位置:首頁 » 安卓系統 » android卡片效果圖

android卡片效果圖

發布時間: 2025-10-15 02:26:18

1. android 安卓 類似ONE卡片頁(包含圖片文字等)怎麼實現

Android5.0中向我們介紹了一個全新的控制項–CardView,從本質上看,可以將CardView看做是FrameLayout在自身之上添加了圓角和陰影效果。請注意:CardView被包裝為一種布局,並且經常在ListView和RecyclerView的Item布局中,作為一種容器使用。

下面例子來源於android學習手冊, android學習手冊包含9個章節,108個例子,源碼文檔隨便看,例子都是可交互,可運行,源碼採用android studio目錄結構,高亮顯示代碼,文檔都採用文檔結構圖顯示,可以快速定位。360手機助手中下載,排在第四個。

CardView應該被使用在顯示層次性的內容時;在顯示列表或網格時更應該被選擇,因為這些邊緣可以使得用戶更容易去區分這些內容。

使用CardView

首先,假設你的布局如同下面的形式:

<FrameLayout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <!-- Main Content View --> <RelativeLayout> ... </RelativeLayout> </FrameLayout>

為了使用上面的布局方式來創建一個卡片,首先你需要導入支持的依賴庫(android-support-v7-cardview的jar包)在你的build.gradle文件中。

dependencies { ... compile 'com.android.support:cardview-v7:21.0.2' }

現在將FrameLayout替換為CardView,

<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <!-- Main Content View --> <RelativeLayout> ... </RelativeLayout> </android.support.v7.widget.CardView>

就是這樣!使用依賴庫能夠保證你的程序穩定的兼容之前的版本;盡管在AndroidL和之前的Android版本中對其處理方式有所不同。

熱點內容
水晶戰爭伺服器怎麼玩 發布:2025-10-15 06:43:05 瀏覽:711
c語言自學視頻教程 發布:2025-10-15 06:09:52 瀏覽:446
oracle資料庫腳本導出 發布:2025-10-15 06:03:18 瀏覽:552
qt編譯pro 發布:2025-10-15 06:03:17 瀏覽:761
兒童編程都在學什麼 發布:2025-10-15 05:45:21 瀏覽:820
python字元整型 發布:2025-10-15 05:43:54 瀏覽:275
平板訪問谷歌 發布:2025-10-15 05:42:28 瀏覽:159
mysql整個資料庫備份 發布:2025-10-15 05:36:52 瀏覽:210
DO2演算法 發布:2025-10-15 05:30:36 瀏覽:691
android主線程ui 發布:2025-10-15 05:30:25 瀏覽:415