gitmyhub

ShadowLayout

Java ★ 3.7k updated 5mo ago

可定制化阴影的万能阴影布局ShadowLayout 3.0 震撼上线。效果赶超CardView。阴影支持x,y轴偏移,支持阴影扩散程度,支持阴影圆角,支持单边或多边不显示阴影;控件支持动态设置shape和selector(项目里再也不用画shape了);支持随意更改颜色值,支持随意更改颜色值,支持随意更改颜色值。重要的事情说三遍

An Android Java library for adding customizable drop shadows, rounded corners, gradients, and tap-state effects to any UI element by wrapping it in a ShadowLayout container.

JavaAndroidJitPacksetup: easycomplexity 2/5

ShadowLayout is an Android UI library written in Java that makes it easy to add drop shadows and visual shape effects to any element in an Android app. Normally, Android developers have to create separate XML drawable files to define shadows, borders, and background shapes for buttons and other components. ShadowLayout replaces that tedious process by letting you configure everything directly in your layout file or in code at runtime.

The core idea is a wrapper component: you place a ShadowLayout around any other UI element, set a few properties, and that element gets a fully customizable shadow. You can control the shadow color, how far it spreads, whether it has rounded corners (and how round each individual corner is), and how much it shifts along the horizontal or vertical axis. You can also hide the shadow on specific sides, so for instance a card might only show a shadow on the bottom and right.

Beyond shadows, the library handles shape and selector behavior. A selector in Android is what defines how a button looks when it is pressed versus when it is idle. Normally that requires extra drawable files, but ShadowLayout builds it in: you set a normal background color and a pressed background color, and the component handles the visual switch automatically. It also supports ripple effects (the circular animation that spreads out from a tap), gradient backgrounds, stroke borders, and image backgrounds with their own pressed states.

One practical feature is binding a ShadowLayout to a text element so the background color automatically follows the text color when that changes. There is also a clipping option, which lets you round or mask the corners of a child view like a video player, something that is otherwise awkward to do in Android.

The library is distributed through JitPack, so adding it to an Android project is a matter of a few lines in the project's build files. It supports AndroidX and has been updated through several major versions, with the 3.x line bringing significant API changes relative to the 2.x series.

Where it fits