Need help with Material-backdrop?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

Semper-Viventem
221 Stars 20 Forks MIT License 108 Commits 4 Opened issues

Description

A simple solution for implementing Backdrop pattern for Android

Services available

!
?

Need anything else?

Contributors list

# 134,647
HTML
Kotlin
custom-...
Android
75 commits

Backdrop

Download

What is it?

This library makes it easy to implement a Backdrop pattern with a CoordinatorLayout

Download

JCenter (Recommended):

groovy
dependencies {
    implementation 'ru.semper-viventem.backdrop:backdrop:0.1.7'
}

JitPack: ```groovy repositories { ... maven { url 'https://jitpack.io' } }

dependencies { implementation 'com.github.Semper-Viventem:BackdropView:0.1.7' } ```

How to use it?

You need to add front layout and back layout (with toolbar) to CoordinatorLayout.

Add BackdropBehavior to your front layout:

XML ```xml

<!-- Must contain a Toolbar -->
<androidx.appcompat.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content"></androidx.appcompat.widget.toolbar>

<!-- For example, NavigationView. Or you can use anything -->
<com.google.android.material.navigation.navigationview android:id="@+id/navigationView" android:layout_width="match_parent" android:layout_height="wrap_content" app:menu="@menu/main_menu"></com.google.android.material.navigation.navigationview>

</com.google.android.material.appbar.appbarlayout>

<android.support.design.card.materialcardview android:id="@+id/foregroundContainer" app:layout_behavior="ru.semper_viventem.backdrop.BackdropBehavior" android:layout_width="match_parent" android:layout_height="match_parent">

<!-- Anything -->

</android.support.design.card.materialcardview>

```

Kotlin

I used this extension to search for behavior: ```kotlin fun > View.findBehavior(): T = layoutParams.run { if (this !is CoordinatorLayout.LayoutParams) throw IllegalArgumentException("View's layout params should be CoordinatorLayout.LayoutParams")

(layoutParams as CoordinatorLayout.LayoutParams).behavior as? T
        ?: throw IllegalArgumentException("Layout's behavior is not current behavior")

} ```

...

val backdropBehavior: BackdropBehavior = foregroundContainer.findBehavior() // find behavior

with(backdropBehavior) {

    // Attach your back layout to behavior.
    // BackDropBehavior will find the toolbar itself.
    attachBackLayout(R.id.backLayout)

    // Set navigation icons for toolbar
    setClosedIcon(R.drawable.ic_menu)
    setOpenedIcon(R.drawable.ic_close)

    // Add listener
    addOnDropListener(object : BackdropBehavior.OnDropListener {
        override fun onDrop(dropState: BackdropBehavior.DropState, fromUser: Boolean) {
            // TODO: handle listener            
        }
    })

}

...

License

MIT License

Copyright (c) 2018 Konstantin Kulikov ([email protected])

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.