This is a fork of AndroidSlidingUpPanel, also inpired by this fork by dlukashev. This is some kind of merge dlukashev's idea into AndroidSlidingUpPanel v.2 with some improvements. For total understanding of how it's done with ScrollView - see this dlukashev's blog post.
You need to understand, that this is a little hacky way, but it's "good enough", as I think.
This library provides a simple way to add a draggable sliding up panel (popularized by Google Music, Google Maps and Rdio) to your Android application. Umano Team <3 Open Source.
As seen in Umano Android app:
You can import it as a Library Project
com.sothree.slidinguppanel.SlidingUpPanelLayout
as the root element in your activity layout.gravity
set to bottom
.match_parent
.match_parent
and the height set to either match_parent
or the max desireable height.setDragView
method or dragView
attribute. For more information, please refer to the sample code.
<com.sothree.slidinguppanel.SlidingUpPanelLayout
xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:panelHeight="68dp"
sothree:shadowHeight="4dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="Main Content"
android:textSize="16sp" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center|top"
android:text="The Awesome Sliding Up Panel"
android:textSize="16sp" />
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
For smooth interaction with the ActionBar, make sure that windowActionBarOverlay
is set to true
in your styles:
<style name="AppTheme">
<item name="android:windowActionBarOverlay">true</item>
</style>
However, in this case you would likely want to add a top margin to your main layout of ?android:attr/actionBarSize
.
dragView
, the panel will pass through the click events to the main layout. Make your second layout clickable
to provent this.setPanelHeight
method or panelHeight
attribute.shadowHeight
attribute to 0.setSlidingEnabled
method. This can be useful if you want to show\hide panel only from the code. By default sliding is enabled.paralaxOffset
attribute (see demo for the example).setAnchorPoint
to allow an intermediate expanded state for the panel (similar to Google Maps).PanelSlideListener
to monitor events about sliding panes.layout_gravity
attribute of the layout to top
.setOverlayed
method or overlay
attribute. This is useful if you would like to make the sliding layout semi-transparent.fadeColor
. Set it to "@android:color/transparent"
to remove dimming completely.This library was initially based on the opened-sourced SlidingPaneLayout component from the r13 of the Android Support Library. Thanks Android team!
Tested on Android 2.2+
If you have an awesome pull request, send it over!
showPanel
/hidePanel
methods. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or 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.