Skip to content

Allows to display a text which wraps around an image (or any other Composable).

License

Notifications You must be signed in to change notification settings

androiddevnotesforks/textflow

 
 

Repository files navigation

Maven Central Maven Central

Text Flow

Text Flow library for Jetpack Compose.

Allows to display a text which wraps around an image (or any other Composable).

From version 1.2.0 now supports both Material 2 and Material 3 themes.

Examples

See Demo application and examples.

Simple text around image

Text wrapping a letter to create a Drop Cap

Animating image size and changing the alignment

Annotated string support

Usage

Get a dependency

Step 1. Add the MavenCentral repository to your build file. Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        mavenCentral()
    }
}

Or in settings.gradle:

dependencyResolutionManagement {
    repositories {
        ...
        mavenCentral()
    }
}

Step 2. Add the dependency. Check latest version on the releases page.

dependencies {
    // For Material 2 theme
    implementation "io.github.oleksandrbalan:textflow:$version"

    // For Material 3 theme
    implementation "io.github.oleksandrbalan:textflow-material3:$version"
}

Use in Composable

The TextFlow behaves as a regular Text, but has 2 more arguments:

  • obstacleContent - The content lambda to provide the obstacle composable which will be wrapped by the text. Could be used as trailing lambda.
  • obstacleAlignment - The alignment of the obstacleContent. Text flow supports TopStart (default) and TopEnd alignments.
TextFlow(
    text = "Text Flow allows to display a text which wraps around an image (or any other Composable)",
    modifier = Modifier.width(220.dp),
    obstacleAlignment = TextFlowObstacleAlignment.TopStart,
    obstacleContent = {
        Icon(
            imageVector = Icons.Default.Done,
            contentDescription = null,
            modifier = Modifier.padding(4.dp)
        )
    }
)

About

Allows to display a text which wraps around an image (or any other Composable).

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Kotlin 100.0%