It is a Side Panel library like the Edge Panel of Galaxy. You can draw a layout using xml and access it like a general View.
-
Add the JitPack repository to your build file.
allprojects { repositories { ... maven { url 'https://jitpack.io' } } }
-
Add the dependency
dependencies { implementation 'com.github.dddh1221:AndroidSidePanel:vX.Y.Z' }
-
Add the JitPack repository to your build file
<repositories> <repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository> </repositories>
-
Add the dependency
<dependency> <groupId>com.github.dddh1221</groupId> <artifactId>AndroidSidePanel</artifactId> <version>vX.Y.Z</version> </dependency>
-
Design your xml like this: Draw a SidePanelLayout on top of all views. And put SidePanelView inside Layout. SidePanelLayout will act as the background of the side panel, and SidePanelView will act as the actual side panel. Other widgets can also be added within the Layout. Widgets other than SidePanelView are treated as a background and the same Alpha value is applied.
One thing to note here is that the Side Panels should always be glued to the right side. If you put a SidePanelView as a SidePanelLayout child view, it will automatically position itself. A SidePanelView should not have a Margin on the right side.
<com.dahun.sidepanel.widget.SidePanelLayout android:id="@+id/panel_layout" android:layout_width="match_parent" android:layout_height="match_parent" app:defaultClosed="true" app:dimBackgroundColor="@color/gray"> <!-- Here you can add a widget to use as a background. --> <com.dahun.sidepanel.widget.SidePanelView android:id="@+id/panel_view" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- Design your side panels here. --> </com.dahun.sidepanel.widget.SidePanelView> </com.dahun.sidepanel.widget.SidePanelLayout>
-
Draw a View to use as a slider to open and close the side panel.
<ImageView android:id="@+id/panel_slider" android:layout_width="wrap_content" android:layout_height="wrap_content" app:src="@drawable/slider"/>
-
Connect the SidePanelLayout with the view used as a slider.
val panelLayout = findViewById<SidePanelLayout>(R.id.panel_layout) val panelSlider = findViewById<ImageView>(R.id.panel_slider) panelLayout.bindSlider(panelSlider)
-
Result
setPanelSlideSensitive(Float)
: Sets the slide sensitivity of the panel. Sensitivity here refers to the sensitivity to open or closed perception. It can be set from 0.0 to 1.0, and the higher the number, the more sensitive it is to small slides.setDimBackgroundMaxAlpha(Float)
: Set the maximum Alpha value of Dim Background. It means the maximum value of the alpha value that changes according to the slide position of the panel.setDimBackgroundColor(Int)
: Change the color of the Dim Background.getPanelState()
: Gets the current state of the panel.SidePanelGestureController.STATE_CLOSED
: Panel closedSidePanelGestureController.STATE_MOVED
: Panel is moving (by Controller)SidePanelGestureController.STATE_DRAGGING
: Panel is moving (by user)SidePanelGestureController.STATE_OPENED
: Panel opened
showPanel()
: Open the panel.dismissPanel()
: Close the panel.bindSlider(View)
: Connect with the slider.
The above settings are also available in xml.
<com.dahun.sidepanel.widget.SidePanelLayout
android:id="@+id/panel_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultClosed="true
app:sliderSensitive="0.7"
app:maxDimAlpha="0.8"
app:dimBackgroundColor="@color/gray">
<!--
app:defaultClosed : Sets the initial state of the panel to close.
-->
</com.dahun.sidepanel.widget.SidePanelLayout>
Copyright 2022 Dahun Kim.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.