Skip to content

nikeorever/floatingview

Repository files navigation

Floating View

Add and manage floating views on the Activity.

This project is currently in development and the API subject to breaking changes without notice.

Usage

class MyActivity : AppCompatActivity() {

    private val floatingViewManager = FloatingViewManager(activity = this)

    private val floatingView: FloatingView by lazy {
        FloatingView.image(this) {
            setImageResource(R.drawable.ic_google)
        }
    }

    fun addFloatingView() {
        if (!floatingViewManager.isFloatingViewAdded(floatingView)) {
            floatingViewManager.addFloatingView(
                floatingView = floatingView,
                layoutParams = FrameLayout.LayoutParams(200, 200),
                onFloatingViewClick = {
                    // TODO do something
                }
            )
        }
    }

    fun removeFloatingView() {
        if (floatingViewManager.isFloatingViewAdded(floatingView)) {
            floatingViewManager.removeFloatingView(floatingView)
        }
    }
}

Download

Artifacts are available in Maven Central at cn.nikeo.floatingview:floatingview:0.1.0.

In-development snapshots are available from Sonatype's snapshot repository.

About

Add and manage floating views on the Activity.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages