Note that there are some explanatory texts on larger screens.

plurals
  1. POTransfer scroll event from sliding view to ScrollView - Sliding panel with ScrollView like Google Maps
    text
    copied!<p>So I'm using the <a href="https://github.com/umano/AndroidSlidingUpPanel" rel="nofollow noreferrer">Sliding Up Panel Library</a> in my application, and I'm trying to implement a <code>ScrollView</code> inside the sliding panel. Since both the sliding panel and the ScrollView are controlled by vertical scrolls, this is causing me some issues.</p> <p>I've partially got it to work by switching the panel's dragview once the panel has been slid all the way up, and when the ScrollView has been scrolled to the top. </p> <p><img src="https://i.stack.imgur.com/4SGnv.jpg" alt="enter image description here"></p> <p>The problem I'm facing now is that, when scrolling the panel to top the scrolling doesn't transfer to the ScrollView, like it does in Google Maps. <strong>Little hard to explain, so look at the video here:</strong> <a href="http://www.youtube.com/watch?v=9MUsmQzusX8&amp;feature=youtu.be" rel="nofollow noreferrer"><strong><em>www.youtube.com/watch?v=9MUsmQzusX8&amp;feature=youtu.be</em></strong></a> </p> <p>This is the panel slide listener:</p> <pre><code>... slidePanel.setEnableDragViewTouchEvents(true); slidePanel.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { @Override public void onPanelSlide(View panel, float slideOffset) { // Change the dragview to panelheader when panel is fully expanded // I'm doing this here instead of in onPanelExpanded, // because onPanelExpanded first gets called once scroll // is released. if (slideOffset &lt;= 0) { slidePanel.setDragView(layoutPanelTop); } // If the panel is not fully expanded set the whole // panel as dragview else if(slideOffset &gt; 0) { slidePanel.setDragView(layoutPanel); } } } @Override public void onPanelExpanded(View panel) { // layout.setDragView(layoutPanelTop); panelCollapsed = false; panelExpanded = true; panelAnchored = false; Log.v("TAG, "panelExpanded"); } @Override public void onPanelCollapsed(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = true; panelExpanded = false; panelAnchored = false; Log.v(TAG, "panelCollapsed"); } @Override public void onPanelAnchored(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = false; panelExpanded = false; panelAnchored = true; Log.v(TAG, "panelAnchored"); } }); </code></pre> <p>And I have managed to create a fully working scrollview listener by extending scrollview, which can detect scroll direction and onDown and onUp motion events:</p> <pre><code>private boolean atScrollViewTop = false; @Override public void onScrollChanged(int scrollY) { scrollY = Math.min(mMaxScrollY, scrollY); if (scrollY &lt;= 0) { Log.v("myTag", "You at scrollview top"); atScrollViewTop = true; } else { atScrollViewTop = false; } mScrollSettleHandler.onScroll(scrollY); switch (mState) { case STATE_SCROLL_UP: if (panelExpanded &amp;&amp; atScrollViewTop) { slidePanel.setDragView(layoutPanel); } else { slidePanel.setDragView(layoutPanelTop); } Log.v("myTag", "scrolling up"); break; case STATE_SCROLL_DOWN: slidePanel.setDragView(layoutPanelTop); Log.v("myTag", "scrolling down"); break; } } @Override public void onDownMotionEvent() { } @Override public void onUpOrCancelMotionEvent() { } </code></pre> <p>I've been struggling with this the last two days.. So really hope on some pointer at least. Thanks very much in advance. Regards Jakob Harteg.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload