2

I have created a demo application using AndroidSlidingPanel Library "https://github.com/umano/AndroidSlidingUpPanel" with a textview as the children. The problem is I cannot click on the label when I tried to click on the label panel slides down.

<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" 
    android:onClick="ClickedOnLabel"
    android:clickable="true"/>

I have come across similar post "Can't click children button in SlidingUpPanelLayout" but could not understand what setdragview is ? and what it does ?

can anyone throw some light how it should be done ?

Community
  • 1
  • 1
forum.test17
  • 2,119
  • 6
  • 30
  • 62

1 Answers1

5

After two days I learnt a lesson that , before using any library read the complete documentation and check with the demo.

I am answering this post if someone has to face the similar problem.

Consider a situation where we have to develop a similar to google maps when clicked on any of the marker in google maps a panel from bottom pops up which has a description of the store and a street view.

In order to do that we have to use AndroidSlidingUpPanel from https://github.com/umano/AndroidSlidingUpPanel

  • If you have any problems in including the library in AndroidStudio, you can follow steps from the following question how to make a sample demo project with Android Sliding panel in Android Stuido

    <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"
        sothree:dragView="@+id/title">
    
  • Inorder to prevent sliding down the panel when clicking on any of the elements in the panel, set the setdragView id to the first element of the child element preferably

  • Set the same id "title" to the textview by using the following code

    android:id="@+id/title"
    

The above step will ensure that sliding down/up of the panels will only happen when you click on the textview of id 'title'

  • In order to listen to the click events on the sliding panel make sure that android:clickable=true is set to the layout , or to the elements

  • Inorder to have anchor point which means that instead of opening the panel completely, it opens the sliding panel to the required position , you can use the following code.

    SlidingUpPanelLayout slidingUpPanelLayout =   (SlidingUpPanelLayout)
    findViewById(R.id.sliding_layout);
    
                //Setting the achor point to the middle of the screen
    
                slidingUpPanelLayout.setAnchorPoint(0.3f);
    

Just in case if someone has the same problem and has been googling around to start with, this will be good start :)

Community
  • 1
  • 1
forum.test17
  • 2,119
  • 6
  • 30
  • 62