Site icon Android Tutorial Online

Android Jetpack Compose Squircle

An Android Jetpack Compose library providing customizable Squircle shapes for UI components

Squircle Shape

An Android Jetpack Compose library providing customizable Squircle shapes for UI components.

Why Squircle?

Requirements

Gradle Kotlin DSL Setup

Step 1

repositories {
    maven(url = "https://jitpack.io")
}

Step 2

implementation("com.github.stoyan-vuchev:squircle-shape:1.0.2")

[libraries]

squircle-shape = { group = “com.github.stoyan-vuchev”, name = “squircle-shape”, version.ref = “squircle-shape” }” style=”box-sizing: border-box; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, “Segoe UI”, Helvetica, Arial, sans-serif, “Apple Color Emoji”, “Segoe UI Emoji”; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;”>

[versions]
squircle-shape = "1.0.2"

[libraries]
squircle-shape = { group = "com.github.stoyan-vuchev", name = "squircle-shape", version.ref = "squircle-shape" }
implementation(libs.squircle.shape)

Step 3

Gradle Groovy Setup

Step 1

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

Step 2

implementation 'com.github.stoyan-vuchev:squircle-shape:1.0.2'

Step 3

Usage

SquircleShape(
    percent = 100,
    cornerSmoothing = 0.72f
)
SquircleShape(
    topStart = 50,
    topEnd = 10,
    bottomStart = 50,
    bottomEnd = 10,
    cornerSmoothing = 0.72f
)
Button(
    onClick = { /* Action */ },
    shape = SquircleShape() // Fully rounded squircle shape.
) {
    Text(text = "Full Squircle")
}
Image(
    modifier = Modifier
        .size(128.dp)
        .clip(shape = SquircleShape()), // Clipped to a fully rounded squircle shape.
    painter = painterResource(R.drawable.mlbb_novaria),
    contentDescription = "An image of Novaria.",
    contentScale = ContentScale.Crop
)

License

This project is open source and available under the MIT License.

Contact

Created by @stoyan-vuchev – feel free to contact me! E-mail – contact.stoyan.vuchev@gmail.com

GitHub

View Github

Exit mobile version