Skip to content

Android viewGroup simulating gravity between child views.

License

Notifications You must be signed in to change notification settings

mrugacz95/GravityView

Repository files navigation

GravityView for Android

This library provides GravityView which is Android ViewGroup with basic physics engine to simulate collisions between it's child views!

Example

Care about lifecycle in your activity:

class MainActivity : AppCompatActivity() {
    // ...

    override fun onPause() {
        super.onPause()
        gravityview.stop()
    }

    override fun onResume() {
        super.onResume()
        gravityview.start()
    }
}

Add GravityView in xml:

<pl.mrugacz95.gravityview.GravityView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/gravityview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_constraintTop_toTopOf="parent"
    app:gravity="9.81">

    <Button android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="65dp"
        android:layout_marginStart="50dp"
        android:text="Hello World!" />

    <TextView android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:layout_marginStart="50dp"
        android:text="Hello World!" />

</pl.mrugacz95.gravityview.GravityView>

Add more view to your needs:

About

Android viewGroup simulating gravity between child views.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages