2018-08-02 Android中實現(xiàn)陰影和圖片圓角效果

Android中實現(xiàn)陰影和圖片圓角效果

這里要講的是兩個github上兩個開源的輪子

圓角效果的依賴

implementation 'com.makeramen:roundedimageview:2.3.0'

陰影效果的依賴

implementation 'com.github.dmytrodanylyk.shadow-layout:library:1.0.3'

圓角依賴使用時,只需要在布局中設(shè)置

<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/incom_center_banner_iv_base"
android:layout_width="match_parent"
android:scaleType="centerCrop"
app:riv_corner_radius="15px"
app:riv_corner_radius_top_left="@dimen/x10"
app:riv_corner_radius_top_right="@dimen/x10"
app:riv_corner_radius_bottom_right="@dimen/x10"
app:riv_corner_radius_bottom_left="@dimen/x10"
app:riv_mutate_background="true"
app:riv_tile_mode="repeat"
android:layout_height="@dimen/x280" />

根據(jù)下面四個值,便可以設(shè)置每個角的度數(shù)

app:riv_corner_radius_top_left="@dimen/x10"
app:riv_corner_radius_top_right="@dimen/x10"
app:riv_corner_radius_bottom_right="@dimen/x10"
app:riv_corner_radius_bottom_left="@dimen/x10"

陰影效果的依賴使用時,也只需要在布局中設(shè)置即可

<com.dd.ShadowLayout
    android:layout_width="match_parent"
    //陰影顏色
    app:sl_shadowColor="#15afafaf"
    android:layout_gravity="center"
    app:sl_shadowRadius="@dimen/x6"
    //陰影距離
    app:sl_cornerRadius="8px"
    //正值,往下偏移,負(fù)值,往上偏移
    app:sl_dy="@dimen/x10"
    //正值,往右偏移,負(fù)值,往左偏移
    app:sl_dx="@dimen/x10"
    android:layout_height="wrap_content">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_gravity="center_horizontal"
        //如果陰影沒有顯示出來,給被ShadowLayout包裹的控件設(shè)置margin值
        android:layout_marginRight="@dimen/x10"
        android:layout_marginLeft="@dimen/x10"
        android:layout_marginTop="@dimen/x8"
        android:layout_marginBottom="@dimen/x8"
        android:background="@drawable/bg_new_re_index"
        android:layout_height="wrap_content">
        <com.makeramen.roundedimageview.RoundedImageView
            android:id="@+id/iv_pager"
            android:layout_width="match_parent"
            android:scaleType="centerCrop"
            app:riv_corner_radius="15px"
            app:riv_mutate_background="true"
            app:riv_tile_mode="repeat"
            android:layout_height="match_parent" />
    </RelativeLayout>
</com.dd.ShadowLayout>
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 178,812評論 25 709
  • 1、通過CocoaPods安裝項目名稱項目信息 AFNetworking網(wǎng)絡(luò)請求組件 FMDB本地數(shù)據(jù)庫組件 SD...
    陽明AI閱讀 16,172評論 3 119
  • 熬夜,晚睡,明明很困,可就是不愿意關(guān)上手機(jī),不愿閉上眼睛。明明已經(jīng)沒有事情,但是非要絞盡腦汁想出一件要做的事來。為...
    雪姨_閱讀 399評論 0 0
  • 打算記錄日常小事,很溫馨的小事。 今天上午,我告訴他我在背英語單詞文科寫作業(yè)。 他說那么認(rèn)真,外加了一個親親的表情...
    沙揚娜拉_閱讀 299評論 0 0
  • 個人主頁,可用于展示自己,亦可作為博客和其他網(wǎng)絡(luò)社區(qū)的連接點。接下來我將來給大家展示如何用1塊錢快速搭建自己的個人...
    cbits閱讀 371評論 0 0

友情鏈接更多精彩內(nèi)容