Crafting a captivating interface is a hallmark of adept Android development, and the TextViewDrawable
library emerges as a potent tool in this endeavor. Developed by Huangweijun, this Kotlin-based library, under the Apache 2.0 license, is a work in progress aimed at simplifying the creation of text and drawable compositions in Android applications.
The TextViewDrawable
library extends a multitude of features:
- It supports a variety of text and drawable composition effects including text backgrounds, text borders, text shadows, and text gradients.
- The library provides the leverage to customize these compositions, unlocking a realm of creative potential.
Embarking on the TextViewDrawable
voyage requires the following code to import the library:
dependencies {
implementation 'com.github.huangweijun:textviewdrawable:1.0.0'
}
Creating a TextView with a text and drawable composition is a breeze:
// Create a TextView
val textView = TextView(context)
// Set the text and drawable composition effect
textView.setDrawableEffect(
drawable = drawable,
text = "Hello, world!",
textStyle = TextStyle.NORMAL,
textColor = Color.BLACK,
textSize = 16f,
)
Extend your creativity further by customizing the composition:
// Customize the text and drawable composition effect
textView.setDrawableEffect(
drawable = drawable,
text = "Hello, world!",
textStyle = TextStyle.ITALIC,
textColor = Color.BLUE,
textSize = 32f,
background = Color.YELLOW,
borderColor = Color.GREEN,
borderWidth = 2f,
shadowColor = Color.GRAY,
shadowRadius = 10f,
shadowOffsetX = 10f,
shadowOffsetY = 10f,
)
TextViewDrawable
is an inviting library for developers of all calibers, although its less active community and documentation are its soft underbelly.