陰影佈局(任何控件只要被他套上,即刻享受你要的陰影效果)

前言: 技術界的小學生一直兜兜轉轉在csdn和簡書上,今天終於加入了這個大圈子。但願慢慢成長爲技術界的大學生。因爲剛用,好多東西都不習慣,那麼先寫一遍試試水。android

先展現個效果圖(包含此控件全部功能,不少小夥伴說陰影不行,博主想說只是截圖分辨率差,還有隻是簡單展現。根據實際UI。經過控件調整顏色,陰影擴散程度和偏移量。會有你想不到的驚喜,好好的乾貨啊)

這個時候你終於能夠跟你的UI小姐姐說,陰影我本身搞定。git

Xml裏只要這樣

<com.lihang.ShadowLayout android:layout_width="wrap_content" android:layout_height="wrap_content" app:hl_cornerRadius="18dp" app:hl_dx="0dp" app:hl_dy="0dp" app:hl_leftShow="false" app:hl_shadowColor="#2a000000" app:hl_shadowLimit="5dp">

        <TextView android:layout_width="wrap_content" android:layout_height="36dp" android:background="@drawable/shape_show_" android:gravity="center" android:paddingLeft="10dp" android:paddingRight="10dp" android:text="徹底圓形圓角" android:textColor="#000" />

    </com.lihang.ShadowLayout>

複製代碼

Api說明:

① 圓角屬性

  • app:hl_cornerRadius="18dp" 陰影圓角屬性

② 陰影擴散程度

  • app:hl_shadowLimit="5dp" 陰影的擴散區域

③ 陰影的顏色

  • app:hl_shadowColor="#2a000000" 陰影的顏色能夠隨便改變,透明度的改變能夠改變陰影的清晰程度

④ x軸的偏移量

  • app:hl_dx="0dp" 也能夠理解爲左右偏移量

⑤ y軸的偏移量

  • app:hl_dy="0dp" 也能夠理解爲上下的偏移量

⑥ 陰影的4邊可見不可見(與偏移量無關)

  • app:hl_leftShow="false" 左邊的陰影不可見,其餘3邊保持不變

github地址詳細請查看,遠程依賴更快捷

本人仍是技術上的小學生。想突破瓶頸,進入到大廠學習,有志同道合的小夥伴,但願聯繫我,一塊兒進步csdngithub

相關文章
相關標籤/搜索