1. 程式人生 > >android 5.0之cardview

android 5.0之cardview

CardView提供了一個預設的elevation(以為CardView的Z軸陰影)和圓角角度

首先我們需要在res/values/attrs中定義屬性

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <declare-styleable name="CardView">
        <attr name="cardBackgroundColor" format="color" />背景色

        <attr name="cardCornerRadius" format=
"dimension" />圓角度 <attr name="cardElevation" format="dimension" />陰影的高度 <attr name="contentPadding" format="dimension" />邊界距離內部的距離 <attr name="contentPaddingLeft" format="dimension" /> <attr name="contentPaddingRight" format="dimension" /> <attr
name="contentPaddingTop" format="dimension" /> <attr name="contentPaddingBottom" format="dimension" /> </declare-styleable> </resources>
佈局檔案:
<android.support.v7.widget.CardView 
    xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:CardView="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/cardView" android:layout_width="500dp" android:layout_height="500dp" android:layout_gravity="center" android:layout_margin="80dp" CardView:cardCornerRadius="14dp" CardView:cardElevation="8dp" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="TextView in CardView" android:textColor="#000000" android:textSize="26sp" /> </android.support.v7.widget.CardView>
我們還需要在build.grade檔案中配置
compile 'com.android.support:cardview-v7:21.0.+'
配置cardView的步驟如下:file--Project Structure--選中當前module的名稱
然後點選右邊的dependencies--點選視窗下方的➕號然後選擇library dependency--
然後選擇com.android.support:cardview-v7:21.0.+點選ok即可完成cardview的配置
效果圖:

相關推薦

android 5.0cardview

CardView提供了一個預設的elevation(以為CardView的Z軸陰影)和圓角角度 首先我們需要在res/values/attrs中定義屬性 <?xml version="1.0" encoding="utf-8"?> <resources&

Android 5.0學習動畫

前言 使用者跟你的App進行互動時,Material Design中的動畫給予使用者動作的反饋和提供視覺的一致感。 包括之前我學習過的: 除我們已經學習過的動畫之外,Material Design還給我們提供了什麼動畫? Touch feedback(觸控反饋)Rev

Android實戰技巧九:最新Android開發環境(Eclipse+ADT+Android 5.0

一、一切由執行時錯誤引起dalvikvm Could not find class '引用包.類', referenced from method... 其實在編譯時也會見到如下錯誤:       [dx]        [dx] trouble processing:   

Android開發者福利--------Android 5.0 API

Android 5.0 API Android 5.0 (LOLLIPOP) 為使用者和應用開發者提供了新功能。本文旨在介紹其中最值得關注的新 API。 如果您有已釋出的應用,請務必看一看 Android 5.0 行為變更,瞭解您的應用應該考慮的變化。即使您不使用

React NativeAndroid 5.0以下系統WebView訪問https頁面變成空白頁

在我們的React Native專案中,需要開發一個tab頁面專門配置三方h5連結,供使用者瀏覽。自動化測試:Android 5.0以下系統此tab頁面為空白頁面。看效果: 而我們去檢視這個三方的

Android學習Android 5.0分享動畫實現微信點選全屏效果

Android5.0過渡動畫,請看 今天用分享動畫實現微信點選全屏效果 本文原始碼下載地址 peizhi 配置 build.gradle: compile 'com.android.support:recyclerview-v7:23.

Android 5.0學習Activity過渡動畫

前言 Activity Transition: 提供了三種Transition型別: 進入:一個進入的過渡(動畫)決定activity中的所有的檢視怎麼進入螢幕。退出:一個退出的過渡(動畫)決定一個activity中的所有檢視怎麼退出螢幕。 共享元素:一個共享元素

Android 5.0學習Activity共享元素過渡動畫

轉自:http://blog.csdn.net/ljx19900116/article/details/41806889 前言 Activity Transition: 提供了三種Transition型別: 進入:一個進入的過渡(動畫)決定activity中的

修復android 5.0 Xutils的框架問題retry error, curr request is null

top ims 訂閱 height trac ber request ext key Android 5.0手機對xUtils-2.6.13.jar請求時會出現retry error, curr request is null 情況, 修復解決方式:

Android 5.0 Lollipop介紹

seq 手勢 不包含 傾斜 pan 配色方案 lol for gles Android Lollipop介紹 Android 5.0 Lollipop,此版本為用戶提供了豐富的新功能,並為開發者新增了數以千計的 API,它進一步擴展了 Android 的應用範圍,從手機

Android探究2:Android 5.0下 Dialog&AlertDialog 並不會影響Activity的生命周期

lac wid cancel test () onclick posit make div 先給出結論:Dialog和AlertDialog並不會影響到Activity的生命周期,但會影響到Activity的優先級。 核心代碼: onCreated中:

Android 5.0+高級動畫開發 矢量圖動畫 軌跡動畫 路徑變換

Android 第1章 課程介紹為了成就更多高逼格的人才,我專門整理了Android5.0以後主推的實現酷炫動畫的新技術,教你掌握實現動畫的高逼格技巧。課程中我會詳細講解每個動畫效果實現的原理和所用的技術,並帶你一步一步的實現每個動畫效果,讓你在學完本次課程後,能夠舉一反三,再也不必擔心設計MM的設計你沒法實

Android 5.0 行為變更

rmi camera rec about md5 加密 進行 評估 訪問權限 stream Android 5.0 除了提供諸多新特性和功能外,還對系統和 API 行為做出了各種變更。本文重點介紹您應該了解並在開發應用時加以考慮的一些主要變更。 如果您之前發布過 Andro

Android 7.0 拍照與圖片裁剪適配

在Android 7.0以上,在相機拍照和圖片裁剪上,可能會碰到以下一些錯誤: Process: com.yuyh.imgsel, PID: 22995 // 錯誤1 android.os.FileUriExposedException: file:///storage/emulate

如何解決Android 5.0中出現的警告:Service Intent must be explicit

有些時候我們使用Service的時需要採用隱私啟動的方式,但是Android 5.0一出來後,其中有個特性就是 Service Intent  must be explitict ,也就是說從Lollipop開始,service服務必須採用顯示方式啟動。

Android 5 0中使用JobScheduler

分享一下我老師大神的人工智慧教程!零基礎,通俗易懂!http://blog.csdn.net/jiangjunshow 也歡迎大家轉載本篇文章。分享知識,造福人民,實現我們中華民族偉大復興!        

Android 5.0及以上WebView不能使用第三方Cookies解決方案

最近在做老專案SDK的升級,突然發現以前能用的功能,現在不能使用了。除錯的時候發現返回了錯誤401.需要認證。奇怪以前都是正常的。所以就去看看webView是否有過變動 解決方法 if (Build.VERSION.SDK_INT >= Build.VERSION_CODE

android 5.0 titilebar分享

colorAccent,colorPrimary,colorPrimaryDark……來這裡你就明白了 伴隨著Android5.0的釋出也更新了support-v7-appcompat到V21,其中增加了ToolBar、recyclerview、cardview等控制元

Android 5.0 and later only support position-independent executables

在參考Android利用tcpdump和wireshark抓取網路資料包使用tcpdump的時候,會提示如下資訊: λ adb shell /data/local/tcpdump "/data/local/tcpdump": error: Android 5.0 and later

Android 5.0 動態許可權申請的基本流程和套路

注:本文主要是梳理一下Android動態許可權申請的一個基本套路。 需要有一定的Android編碼經驗,對於完全的新手來說,可能還有些技術細節沒有做具體解釋。 Android動態許可權申請有效保證了使用者的的安全,但是對開發者來說需要寫跟多的程式碼邏輯來跟使用者確認許可權。 先不考慮