Skip to content

DraggableView is an Android library to make floating draggable view easily using extensions on Kotlin & provided utils class on Java

License

Notifications You must be signed in to change notification settings

axzae/draggable-view

 
 

Repository files navigation

DraggableView

build github tag maven central

DraggableView is an Android library to make floating draggable view easy.

This is the enhancement version of hyuwah's DraggableView. By using this version, you can:

  • Embrace full AndroidX (with Jetifier disabled)
  • Use MavenCentral
  • Fix sticky calculation issue

Setup

Gradle

// build.gradle.kts (app module)

dependencies {
    implementation("com.axzae:draggable-view:1.1.0")
}

Usage

In layout.xml:

<LinearLayout
    android:id="@+id/layout_jail"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="48dp"
    android:background="#40003300"
    android:orientation="vertical">

    <LinearLayout
      android:id="@+id/layout_text"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:background="#a0f3409a"
      android:orientation="vertical"
      android:padding="8dp">

      <TextView
        android:id="@+id/text_x"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/text_x" />

      <TextView
        android:id="@+id/text_y"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/text_y" />
    </LinearLayout>
  </LinearLayout>

In fragment.kt:

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
    DraggableView.Builder(binding.layoutText)
        .setStickyMode(DraggableView.Mode.STICKY_XY)
        .build()
}

See Also

About

DraggableView is an Android library to make floating draggable view easily using extensions on Kotlin & provided utils class on Java

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Kotlin 95.8%
  • Java 4.2%