Skip to content

android hollowout drawable, 自定义遮罩模糊图层,边角形状支持圆角和直角,可以装饰边角线

Notifications You must be signed in to change notification settings

xuie0000/hollowout-drawable

Repository files navigation

android hollowout drawable

镂空遮罩图层库是为了适配网易云Video的封面时看到有一层图层,且转角还画了线,没有找到好的方案就自己写成了库

Notes: library use 'androidx.palette:palette-ktx'

Including in your project

Maven Central

repositories add mavenCentral()

implementation "com.xuie0000:hollowout.drawable:1.0.5"

Usage

support AppCompatImageView&ShapeableImageView hollow out drawable

<com.xuie0000.hollowout.drawable.HollowOutImageView
    android:id="@+id/image"
    android:layout_width="match_parent"
    android:layout_height="160dp"
    android:scaleType="centerCrop"
    app:hollow_out_padding="18dp"
    app:hollow_out_shape="round_corner"
    app:layout_constraintTop_toTopOf="parent" />
<com.xuie0000.hollowout.drawable.HollowOutShapeableImageView
    android:id="@+id/image"
    android:layout_width="match_parent"
    android:layout_height="160dp"
    android:scaleType="centerCrop"
    app:hollow_out_padding="18dp"
    app:hollow_out_shape="round_corner"
    app:layout_constraintTop_toTopOf="parent"
    app:shapeAppearanceOverlay="@style/roundedCornerStyle" />

if you load net-image, need disable hardware function

binding.image.load(url) {
  allowHardware(false)
}

属性介绍

Attribute Type Default Description
hollow_out_padding dimension 40dp padding to view side
hollow_out_paddingStart dimension start/left padding to view side
hollow_out_paddingTop dimension top padding to view side
hollow_out_paddingEnd dimension end/right padding to view side
hollow_out_paddingBottom dimension bottom padding to view side
hollow_out_shape enum round_corner shapes, include round_corner,circle,oval,rectangle
hollow_out_color color null if the color exist, will replace blur image
hollow_out_roundCorner dimension 10dp round corner radius
hollow_out_roundCornerStroke dimension round corner stroke width
hollow_out_roundCornerColor color 10dp round corner stroke color

References

https://zhuanlan.zhihu.com/p/329825945 https://xuie0000.com/post/2021-06-18-netease-10-hollowout-drawable.html

About

android hollowout drawable, 自定义遮罩模糊图层,边角形状支持圆角和直角,可以装饰边角线

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages