LetteredIconView is an android view library to show a letter inside a shape as a view.
It may have a circular, rounded and a square shape.
Use it in your xml layout as:
<com.kishannareshpal.lettericonview.LetterIconView
android:layout_width="64dp"
android:layout_height="64dp"
app:liv_shape="square"
app:liv_isGradient="true"
app:liv_backgroundColor="#EFCB68"
app:liv_letters="Galantis" />
Attribute | Type | Possible Values |
---|---|---|
app:liv_shape | enum | circle round_square square |
app:liv_isGradient | boolean | true false |
app:liv_backgroundColor | color | any color reference (@color/name) or hex (#EFCB68) |
app:liv_letters | string | any length of string. will only show the first two letters of the string with the first letter always capitalized. So you might aswell just put a two character string. |
app:liv_shape // to set the shape of the view. (Default: circle)
app:liv_isGradient // if you want to use a gradient on the shape's color. (Default: true)
app:liv_backgroundColor // to manually set the shape color. (Default: a color based on the first letter,
// or lightgrey if the letters attribute is not set)
app:liv_letters // characters to show inside the shape. (Default: "" – EMPTY)
// Note: the letters text color will be automatically set to either Light or a Dark color based on the liv_backgroundColor that is set.
LetterIconView liv = findViewById(...)
liv.shape(Shape shape) // to change the icon shape {@see LetterIconView.Shape} enum class
liv.letters(String letters) // to change the text inside the icon view. Note that only the first two letters of the string will be shown.
Add it via Gradle:
dependencies {
// ...
implementation 'com.kishannareshpal:lettericonview:<version>'
// ...
}
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.