Description
A ViewGroup that implements a sliding panel that is part of the view hierarchy, not above it.
All other implementations of the bottom sheet pattern and sliding panel pattern implement a panel that sits above all the other Views of the app. When the panel is collapsed (but visible) the only way to set its position is by using a peek factor (its distance from the bottom of the screen).
With this library the sliding panel is placed exactly where it is supposed to be in the view hierarchy, just like it would be in a vertical (or horizontal) LinearLayout. It doesn't sit above other Views.
sliding-panel alternatives and similar packages
Based on the "Kotlin" category.
Alternatively, view sliding-panel alternatives based on common mentions on social networks and blogs.
-
android-youtube-player
YouTube Player library for Android and Chromecast, stable and customizable. -
CalendarView
A highly customizable calendar view and compose library for Android. -
Balloon
:balloon: Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android. -
Kotterknife
Android view injection writen in Kotlin based on ButterKnife -
Shortbread
Android library that creates app shortcuts from annotations -
kotlin-android-template
Android + Kotlin + Github Actions + ktlint + Detekt + Gradle Kotlin DSL + buildSrc = โค๏ธ -
NotyKT ๐๏ธ
๐ NotyKT is a complete ๐Kotlin-stack (Backend + Android) ๐ฑ application built to demonstrate the use of Modern development tools with best practices implementation๐ฆธ. -
Material Chip View
Material Chip view. Can be used as tags for categories, contacts or creating text clouds -
DrawableToolbox
๐ ๏ธ The missing drawable toolbox for Android. Create drawables programmatically and get rid of the boring and always repeated drawable.xml files. -
Navigation Toolbar for Android
:octocat: Navigation toolbar is a slide-modeled UI navigation controller made by @Ramotion -
CodeView
Display code with syntax highlighting :sparkles: in native way. -
Carousel Recyclerview
Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager. -
Pluto Debug Framework
Pluto is a on-device debugging framework for Android applications, which helps in inspection of HTTP requests/responses, capture Crashes and ANRs and manipulating application data on-the-go. -
MaterialTimelineView
With MaterialTimelineView you can easily create a material looking timeline. -
CrunchyCalendar โ awesome calendar widget for android apps
A beautiful material calendar with endless scroll, range selection and a lot more! -
Android Kotlin Samples
Some basic samples of Kotlin for Android -
MaterialDrawerKt
A Kotlin DSL wrapper around the mikepenz/MaterialDrawer library. -
Pdf Viewer For Android
A Lightweight PDF Viewer Android library which only occupies around 125kb while most of the Pdf viewer occupies up to 16MB space. -
Capturable
๐Jetpack Compose utility library for capturing Composable content and transforming it into Bitmap Image๐ผ๏ธ -
Transition X
{ } Declarative Kotlin DSL for choreographing Android transitions -
Only
:bouquet: An easy way to persist and run code block only as many times as necessary on Android. -
SSComposeCookBook
A Collection of major Jetpack compose UI components which are commonly used.๐๐๐ -
Swagger Gradle Codegen
๐ซ A Gradle Plugin to generate your networking code from Swagger -
SSCustomBottomNavigation
Animated TabBar with native control and Jetpack Navigation support..โจ๐๐ -
EasyPermissions-ktx
๐ Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher. -
Awesome Jetpack compose
A collaborative list of awesome jetpack compose resources. -
DeviceInfo-Sample
[Android Library] Get easy access to device information super fast, real quick -
Permission Flow for Android
Know about real-time state of a Android app Permissions with Kotlin Flow APIs. -
CameraViewEx
Easy Android camera integration, advanced features. -
Aimybox voice assistant
Embeddable custom voice assistant for Android applications -
Nextflix-Composable
Includes jetpack compose, navigation, paging, hilt, retrofit, coil, coroutines, flow.. -
Intro Showcase View
Highlight different features of the app using Jetpack Compose -
Events Calendar
Events Calendar is a user-friendly library that helps you achieve a cool Calendar UI with events mapping. You can customise every pixel of the calendar as per your wish and still achieve in implementing all the functionalities of the native android calendar in addition with adding dots to the calendar which represents the presence of an event on the respective dates. It can be done easily, you are just a few steps away from implementing your own badass looking Calendar for your very own project! -
ZoomHelper
ZoomHelper will make any view to be zoomable just like Instagram pinch-to-zoom -
SSCustomEditTextOutLineBorder
Same as the Outlined text fields presented on the Material Design page but with some dynamic changes. ๐ ๐ -
Vanilla Place Picker
Simple(vanilla) yet 'Do it all' place picker for your place picking needs in Android -
Maildroid
Maildroid is a small robust android library for sending emails using SMTP server -
Mutekt
Simplify mutating "immutable" state models (a Kotlin multiplatform library) -
Turtle ๐ข
Run shell commands from a Kotlin script or application with ease -
Crowdin Android SDK
Crowdin Android SDK delivers all new translations from Crowdin project to the application immediately -
TimelineView
A customizable and easy-to-use Timeline View library for Android. Works as a RecyclerView decorator (ItemDecoration) -
Compose Compiler Reports to HTML Generator
A utility (Gradle Plugin + CLI) to convert Jetpack Compose compiler metrics and reports to beautified HTML page. -
EasyCrypt
Android cryptography library with SecureRandom patches.
Appwrite - The Open Source Firebase alternative introduces iOS support
Do you think we are missing an alternative of sliding-panel or a related project?
README
sliding-panel
A ViewGroup that implements a sliding panel that is part of the view hierarchy, not above it.
Difference from other libraries
All other implementations of the bottom sheet pattern and sliding panel pattern implement a panel that sits above all the other Views of the app. When the panel is collapsed (but visible) the only way to set its position is by using a peek factor (its distance from the bottom of the screen).
With this library the sliding panel is placed exactly where it is supposed to be in the view hierarchy, just like it would be in a vertical (or horizontal) LinearLayout
. It doesn't sit above other Views.
Overview
SlidingPanel
is a ViewGroup exending FrameLayout
.
It has exacly two children: a non sliding view and a sliding view.
- The non sliding view is just a view that doesn't move, positioned as if
SlidingPanel
was aLinearLayout
. - The sliding view is a View that can be dragged by the user. It slides over the non sliding view, both vertically and horizontally.
The sliding view can be collapsed or expanded.
- When collapsed, the sliding view is exactly where it would be if
SlidingPanel
was a LinearLayout. - When expanded, the sliding view is positioned to exactly cover the non sliding view. (Therefore the maximum amount of movement allowed to the sliding view is equal to the height (or width) of the non sliding view)
Sample app
You can download the apk of the sample app [at this link](./sample-app/apk), or on the PlayStore.
The code of the sample app is available [at this link](./sample-app/).
Having the sample apps installed is a good way to be notified of new releases. Although watching this repository will allow GitHub to email you whenever a new release is published.
Download
The Gradle dependency is available via jCenter. jCenter is the default Maven repository used by Android Studio.
The minimum API level supported by this library is API 15.
dependencies {
implementation 'com.psoffritti.slidingpanel:core:1.0.0'
}
Quick start
In order to start using the library you need to add a SlidingPanel
to your layout.
<com.psoffritti.slidingpanel.SlidingPanel
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_panel"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:orientation="vertical"
app:nonSlidingView="@id/non_sliding_view"
app:slidingView="@id/sliding_view"
app:elevation="4dp" >
<TextView
android:id="@+id/non_sliding_view"
android:layout_width="match_parent"
android:layout_height="150dp"
android:gravity="center"
android:text="non sliding view"
android:background="#af4448" />
<TextView
android:id="@+id/sliding_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="sliding view"
android:background="#e57373" />
</com.psoffritti.slidingpanel.SlidingPanel>
non_sliding_view
and sliding_view
can be whatever View or ViewGroup you need.
If you want to listen to slide events, you can add a OnSlideListener
to the SlidingPanel
.
sliding_panel.addSlideListener { slidingPanel, state, currentSlide ->
when(state) {
PanelState.COLLAPSED -> { }
PanelState.EXPANDED -> { }
PanelState.SLIDING -> { }
}
}
API documentation
Table of contents
SlidingPanel attributes
SlidingPanel
has a set of attributes that you can set to customize its behviour. Some of this attributes are mandatory.
slidingView
Mandatory: yes -- Value: view reference -- Default: null
This mandatory attribute is used to tell SlidingPanel
which of its two children is the sliding view. If this attribute is not set SlidingPanel
will throw an Excpetion.
<com.psoffritti.slidingpanel.SlidingPanel
...
app:slidingView="@id/sliding_view" >
...
</com.psoffritti.slidingpanel.SlidingPanel>
nonSlidingView
Mandatory: yes -- Value: view reference -- Default: null
This mandatory attribute is used to tell SlidingPanel
which of its two children is the non sliding view. If this attribute is not set SlidingPanel
will throw an Excpetion.
<com.psoffritti.slidingpanel.SlidingPanel
...
app:nonSlidingView="@id/non_sliding_view" >
...
</com.psoffritti.slidingpanel.SlidingPanel>
dragView
Mandatory: no -- Value: view reference -- Default: slidingView
This attribute is used to tell SlidingPanel
which View should be used to drag the sliding view. If not set this value defaults to the sliding view. Therefore the whole panel will be sensible to dragging.
Note that if the whole panel is draggable it won't be possible to use scrollable views inside the sliding view.
<com.psoffritti.slidingpanel.SlidingPanel
...
app:dragView="@id/drag_view" >
...
</com.psoffritti.slidingpanel.SlidingPanel>
fitToScreenView
Mandatory: no -- Value: view reference -- Default: null
When collapsed, the sliding view is shifted down (or right) by an amount equal to the height (or width) of the non sliding view. Therefore, when collapsed, the bottom (or right) part of the sliding view will be out of the screen.
This attribute is used to tell SlidingPanel
that we want a view to be shifted up (or left) so that it is always visible.
See the screenshots below to better understand. In the first one fitToScreenView
is set, in the second one it isn't.
[fitToScreenView](./images/fitToScreenView.png)
Notice the white text at the bottom of the screen. It is not visible in the second screen, it is visible only when the panel is expanded.
The sample app has [an example specific for this attribute](./sample-app/src/main/java/com/psoffritti/slidingpanel/sampleapp/examplesfittoscreenview/FitToScreenViewExampleActivity.kt).
<com.psoffritti.slidingpanel.SlidingPanel
...
app:fitToScreenView="@id/fit_to_screen_view" >
...
</com.psoffritti.slidingpanel.SlidingPanel>
orientation
Mandatory: no -- Value: vertical
| horizontal
-- Default: vertical
This attribute is used to set the orientation of SlidingPanel
in the same way that it is used for a LinearLayout
. By default it is set to vertical
.
<com.psoffritti.slidingpanel.SlidingPanel
...
app:orientation="horizontal" >
...
</com.psoffritti.slidingpanel.SlidingPanel>
elevation
Mandatory: no -- Value: dimension -- Default: 4dp
This attribute is used to set the length of the shadow drawn to the top (or left) side of the sliding view.
<com.psoffritti.slidingpanel.SlidingPanel
...
app:elevation="10dp" >
...
</com.psoffritti.slidingpanel.SlidingPanel>
API
You can interact with SlidingPanel
programmatically through its API.
Panel state
SlidingPanel
has a state that can be one of: EXPANDED
, COLLAPSED
and SLIDING
.
You can get
the state but are not allowed to set it directly.
To programmatically change the state of the panel you should use the slideTo
method.
slideTo
This method takes as argument one of the possible states of the panel: EXPANDED
, COLLAPSED
. If you try to pass SLIDING
the panel will throw an IllegalArgumentException
.
When this method is called the panel will automatically animate to to match the state passed as argument.
slideDuration
You can set the duration of the slide animation using the slideDuration
property.
This property affects:
- the duration of the slide triggered by
slideTo
. - the speed at which the panel autocompletes the slides when the user stops dragging it before reaching the
EXPANDED
orCOLLAPSED
state.
You can use the constants defined in SlidingPanel
(SlidingPanel.SLIDE_DURATION_SHORT
, SlidingPanel.SLIDE_DURATION_LONG
) or set it to an arbitrary duration in millisecond.
sliding_panel.slideDuration = SlidingPanel.SLIDE_DURATION_SHORT
sliding_panel.slideDuration = SlidingPanel.SLIDE_DURATION_LONG
Programmatically set drag view
Sometimes it is usefull to change the dragView at runtime.
[An example is give in the sample app, in the "advanced example"](./sample-app/src/main/java/com/psoffritti/slidingpanel/sampleapp/examples/advanced). In this case a list is shown when the panel is expanded, therefore the drag view has to be changed. Otherwise the list wouldn't be scrollable.
Use the setDragView(view: View)
method to programmatically set the drag view.
Listen to events
You can listen to slide events, by adding an OnSlideListener
to the SlidingPanel
.
sliding_panel.addSlideListener { slidingPanel, state, currentSlide ->
when(state) {
PanelState.COLLAPSED -> { }
PanelState.EXPANDED -> { }
PanelState.SLIDING -> { }
}
}
or
sliding_panel.addSlideListener(object : SlidingPanel.OnSlideListener {
override fun onSlide(slidingPanel: SlidingPanel, state: PanelState, currentSlide: Float) { }
})
- The first argument is a referece to the
SlidingPanel
emitting the event. - The second argument is the current state of the panel.
- The third argument is a value between 0 and 1. The value is 0 when the state is
COLLAPSED
and 1 whenEXPANDED
.
For any question feel free to open an issue on the GitHub repository.