4

I need to do a Sliding Up View wich should slide up from the bottom of the screen when I click a button. It has to show on the bottom of the screen and I need to slide/drag it to the center of the screen. The images below explain it better. almost like the AndroidSlidingUpPanel from "umano" which you can find here:

The problem is that I want the first child (The content of my View - an image for example) to fill all the screen and also I want the second child(the actual bottom bar) to be showed when I click a button. The images below explain it better. If there is not possible to do this by changing the AndroidSlidingUpPanel, how can I do that? I have never worked with views like this. I would really appreciate any tip or help. Thank you very much.

enter image description here

Prasanth S
  • 3,725
  • 9
  • 43
  • 75
stanete
  • 4,062
  • 9
  • 21
  • 30
  • possible duplicate of [Replicate Google Maps Bottom Panel Swipe Up](http://stackoverflow.com/questions/21826892/replicate-google-maps-bottom-panel-swipe-up) – reixa Feb 18 '14 at 09:29
  • It is not a duplicate. I want my view to appear when I click the button, I do not want it to be already there. – stanete Feb 18 '14 at 10:30
  • Take a look at https://github.com/Ali-Rezaei/SlidingDrawer which makes it possible to slide from any side by few lines of code, and much more simpler than slidingUpPanel to work with. – Ali Jun 13 '15 at 19:42
  • Best way to achieve this use Android Bottom sheet. – Md Imran Choudhury Mar 24 '19 at 04:40

4 Answers4

2

To hide or show panel, you can use

showPanel()

method.

To hide it try this:

SlidingUpPanelLayout slidingPanel = (SlidingUpPanelLayout) findViewById(R.id.sliding_panel); slidingPanel.hidePanel();

To make it appe

SlidingUpPanelLayout slidingPanel = (SlidingUpPanelLayout) findViewById(R.id.sliding_panel); slidingPanel.showPanel();

This is available only in v 2.0 of AndroidSlidingUpPanel (https://github.com/umano/AndroidSlidingUpPanel). As I know, it's included in android support library v13 now, but not sure if there is latest version.

arbuzz
  • 396
  • 3
  • 12
0

You can check this library for dragging content from all four edges of the screen https://github.com/SimonVT/android-menudrawer

You can make a custom layout inside this menu drawer to get your expected result.

Abhishek Agarwal
  • 1,907
  • 12
  • 21
0

You can do it with AndroidSlidingUpPanel, just set visibility:

android:visibility="GONE"

on the 2° child of the view (the panel) and use .showPane() and .hidePane() on SlidingUpPanelLayout to show/hide the panel when you click the button.

Miroslav Trninic
  • 3,327
  • 4
  • 28
  • 51
Francesco
  • 1
  • 1
  • And is there any way to set the 2º Child to fill the screen? Because doing it how you say, the 2º child moves when I use .showPane() on SlidingUpPanelLayout. – stanete Feb 18 '14 at 11:40
  • What do you mean with "moves"? It is shown on the screen the 2° child? Use 'expandPane()' to expand the panel and fill the screen. – Francesco Feb 18 '14 at 17:32
  • Sorry. I mean the 1º child. I want the 1º child to fill the screen and stay that way. When I call showPan() and the 2º child shows up, it moves the 1º child. – stanete Feb 18 '14 at 17:39
0

The following library do it as well

https://github.com/Paroca72/sc-widgets

Inside you will find a widget named ScSlidingPanel. This widget work different from the other and can be use and customize very easily. You put it inside a RelativeLayout give an alignment and it will open from that side.. Left, Right, Top and Bottom or mixed..

In your specific case your must align your panel at bottom of the container and it will sliding from the bottom.

<!-- Define the container -->
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <!-- Sliding from top -->
    <scapps.com.library.ScSlidingPanel
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true">

            <!-- HERE THE YOUR CONTENT -->
            <!-- or you can load by setLayout method -->

    </scapps.com.library.ScSlidingPanel>

</RelativeLayout>

Another important property that you can use right for your case is the handle size.

You can define an handle and define the beavior of it.. as your image above you used a button.. you can unsing an image and setting setToggleOnTouch() to true for open/close the panel touching on handle.

Samuele
  • 129
  • 11