Litho provides extensive support for stylized borders on component layouts. All of the available options are specified through a
Border object via a builder pattern.
Litho supports setting a border width for all edges, or a different width per edge. Specifying a width for a certain edge is done via the various
width builder methods.
For example, let's say you wanted to specify a 10 dip border width for all edges:
Or that you'd like to specify specific widths for a specific edge:
Maybe you just want something different per edge:
Setting a color for a certain border edge is set via the various
color builder methods.
You can set each border edge to any color you'd like:
It still works for varying widths:
You may also set a separate radius value per corner:
Border effects are powerful tools to help you stylize your borders even further. The following effects are currently available:
Under the hood, each effect utilizes a standard PathEffect supplied by the Android Framework. You may use up to two effects at the same time. If you use two effects, they will both be composed with each other in the order given.
Border effects are specified via the various
*Effect methods on the
Currently Litho does not support varying border widths with effects. Each border width must be the same.
The dash effect applies a sequence of "on" and "off" sections of the border color. This effect utilizes DashPathEffect internally.
The discrete effect will divide your border into segments whereby each segment will randomly deviate in the cross axis. This effect utilizes DiscretePathEffect internally.
Path dash will take in a custom Android path object and continually stamp the path along the border. This effect utilizes PathDashPathEffect internally.
You may compose multiple effects by simply specifying more than one. This effect utilizes ComposePathEffect internally.
Currently Litho does not support composing more than two effects.