學(xué)習(xí)使用MaterialDesign控件(三)使用CardView實(shí)現(xiàn)卡片效果

本文主要介紹CardView的使用,CardView是繼承自FrameLayout,使用比較簡(jiǎn)單,只需要用CardView包含其他View就可以實(shí)現(xiàn)卡片效果了。

創(chuàng)新互聯(lián)建站一直在為企業(yè)提供服務(wù),多年的磨煉,使我們?cè)趧?chuàng)意設(shè)計(jì),全網(wǎng)整合營(yíng)銷推廣到技術(shù)研發(fā)擁有了開(kāi)發(fā)經(jīng)驗(yàn)。我們擅長(zhǎng)傾聽(tīng)企業(yè)需求,挖掘用戶對(duì)產(chǎn)品需求服務(wù)價(jià)值,為企業(yè)制作有用的創(chuàng)意設(shè)計(jì)體驗(yàn)。核心團(tuán)隊(duì)擁有超過(guò)10多年以上行業(yè)經(jīng)驗(yàn),涵蓋創(chuàng)意,策化,開(kāi)發(fā)等專業(yè)領(lǐng)域,公司涉及領(lǐng)域有基礎(chǔ)互聯(lián)網(wǎng)服務(wù)服務(wù)器托管、成都APP應(yīng)用開(kāi)發(fā)、手機(jī)移動(dòng)建站、網(wǎng)頁(yè)設(shè)計(jì)、網(wǎng)絡(luò)整合營(yíng)銷。

實(shí)現(xiàn)效果如下:

學(xué)習(xí)使用Material Design控件(三)使用CardView實(shí)現(xiàn)卡片效果

加入依賴庫(kù)

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

Layout布局

 <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardCornerRadius="10dp"
        app:cardElevation="10dp"
        android:layout_marginBottom="@dimen/card_margin"
        android:layout_marginLeft="@dimen/card_margin"
        android:layout_marginRight="@dimen/card_margin">

        <LinearLayout
          
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:orientation="horizontal">

          <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/book1" />

          <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:orientation="vertical">

            <TextView
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:text="@string/book_title_1"
              android:textAppearance="@style/TextAppearance.AppCompat.Title"
              android:textColor="@color/primary_text" />

            <TextView
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_marginTop="2dp"
              android:text="@string/book_description_1"
              android:textColor="@color/secondary_text" />
          </LinearLayout>

        </LinearLayout>

</android.support.v7.widget.CardView>

app:cardBackgroundColor 設(shè)置CardView背景顏色
app:cardCornerRadius 設(shè)置CardView圓角大小
app:cardElevation 設(shè)置CardView陰影高度

項(xiàng)目源碼已發(fā)布到Github,以后慢慢加入其他控件的使用。
 源碼地址:MaterialDesignExample

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。

網(wǎng)站標(biāo)題:學(xué)習(xí)使用MaterialDesign控件(三)使用CardView實(shí)現(xiàn)卡片效果
文章位置:http://muchs.cn/article38/ihjdsp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)建站、網(wǎng)站內(nèi)鏈、網(wǎng)站設(shè)計(jì)公司、響應(yīng)式網(wǎng)站做網(wǎng)站、定制網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁(yè)設(shè)計(jì)公司