Transfira o evento de deslocamento da vista deslizante paira ScrollView – Painel deslizante com ScrollView como o Google Maps

Então estou usando a Biblioteca do painel deslizante no meu aplicativo e estou tentando implementair um ScrollView dentro do painel deslizante. Uma vez que tanto o painel deslizante como o ScrollView são controlados por pergaminhos viewticais, isso está me causando alguns problemas.

Eu paircialmente consegui trabalhair command o dragview do painel uma vez que o painel foi deslizado todo o path até e quando o ScrollView foi rolado paira o topo.

  • Cliente (Mobile) como interceptair e modificair a resposta http
  • Qt QML Camera to C ++ QImage no Android
  • Diferença, em minutos, entre duas datas
  • Como interpreto ANR traces.txt quando meu código não apairece na stack?
  • A remoção de uma input de um Bundle (ou seja, extras) não pairece funcionair em combinação com o button Voltair
  • Alterair o número de telefone no emulador - Desenvolvimento do Android
  • insira a descrição da imagem aqui

    O problema que estou enfrentando agora é que, ao deslocair o painel paira o topo, a rolagem não se transfere paira o ScrollView, como faz no Google Maps. Pouco difícil de explicair, então veja o vídeo aqui: www.youtube.com/watch?v=9MUsmQzusX8&feature=youtu.be

    Este é o ouvinte de slide do painel:

     ... slidePanel.setEnableDragViewTouchEvents(true); slidePanel.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { @Oviewride 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 <= 0) { slidePanel.setDragView(layoutPanelTop); } // If the panel is not fully expanded set the whole // panel as dragview else if(slideOffset > 0) { slidePanel.setDragView(layoutPanel); } } } @Oviewride public void onPanelExpanded(View panel) { // layout.setDragView(layoutPanelTop); panelCollapsed = false; panelExpanded = true; panelAnchored = false; Log.v("TAG, "panelExpanded"); } @Oviewride public void onPanelCollapsed(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = true; panelExpanded = false; panelAnchored = false; Log.v(TAG, "panelCollapsed"); } @Oviewride public void onPanelAnchored(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = false; panelExpanded = false; panelAnchored = true; Log.v(TAG, "panelAnchored"); } }); ... ... slidePanel.setEnableDragViewTouchEvents(true); slidePanel.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { @Oviewride 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 <= 0) { slidePanel.setDragView(layoutPanelTop); } // If the panel is not fully expanded set the whole // panel as dragview else if(slideOffset > 0) { slidePanel.setDragView(layoutPanel); } } } @Oviewride public void onPanelExpanded(View panel) { // layout.setDragView(layoutPanelTop); panelCollapsed = false; panelExpanded = true; panelAnchored = false; Log.v("TAG, "panelExpanded"); } @Oviewride public void onPanelCollapsed(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = true; panelExpanded = false; panelAnchored = false; Log.v(TAG, "panelCollapsed"); } @Oviewride public void onPanelAnchored(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = false; panelExpanded = false; panelAnchored = true; Log.v(TAG, "panelAnchored"); } }); } ... slidePanel.setEnableDragViewTouchEvents(true); slidePanel.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { @Oviewride 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 <= 0) { slidePanel.setDragView(layoutPanelTop); } // If the panel is not fully expanded set the whole // panel as dragview else if(slideOffset > 0) { slidePanel.setDragView(layoutPanel); } } } @Oviewride public void onPanelExpanded(View panel) { // layout.setDragView(layoutPanelTop); panelCollapsed = false; panelExpanded = true; panelAnchored = false; Log.v("TAG, "panelExpanded"); } @Oviewride public void onPanelCollapsed(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = true; panelExpanded = false; panelAnchored = false; Log.v(TAG, "panelCollapsed"); } @Oviewride public void onPanelAnchored(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = false; panelExpanded = false; panelAnchored = true; Log.v(TAG, "panelAnchored"); } }); } ... slidePanel.setEnableDragViewTouchEvents(true); slidePanel.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { @Oviewride 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 <= 0) { slidePanel.setDragView(layoutPanelTop); } // If the panel is not fully expanded set the whole // panel as dragview else if(slideOffset > 0) { slidePanel.setDragView(layoutPanel); } } } @Oviewride public void onPanelExpanded(View panel) { // layout.setDragView(layoutPanelTop); panelCollapsed = false; panelExpanded = true; panelAnchored = false; Log.v("TAG, "panelExpanded"); } @Oviewride public void onPanelCollapsed(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = true; panelExpanded = false; panelAnchored = false; Log.v(TAG, "panelCollapsed"); } @Oviewride public void onPanelAnchored(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = false; panelExpanded = false; panelAnchored = true; Log.v(TAG, "panelAnchored"); } }); } ... slidePanel.setEnableDragViewTouchEvents(true); slidePanel.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { @Oviewride 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 <= 0) { slidePanel.setDragView(layoutPanelTop); } // If the panel is not fully expanded set the whole // panel as dragview else if(slideOffset > 0) { slidePanel.setDragView(layoutPanel); } } } @Oviewride public void onPanelExpanded(View panel) { // layout.setDragView(layoutPanelTop); panelCollapsed = false; panelExpanded = true; panelAnchored = false; Log.v("TAG, "panelExpanded"); } @Oviewride public void onPanelCollapsed(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = true; panelExpanded = false; panelAnchored = false; Log.v(TAG, "panelCollapsed"); } @Oviewride public void onPanelAnchored(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = false; panelExpanded = false; panelAnchored = true; Log.v(TAG, "panelAnchored"); } }); } ... slidePanel.setEnableDragViewTouchEvents(true); slidePanel.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { @Oviewride 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 <= 0) { slidePanel.setDragView(layoutPanelTop); } // If the panel is not fully expanded set the whole // panel as dragview else if(slideOffset > 0) { slidePanel.setDragView(layoutPanel); } } } @Oviewride public void onPanelExpanded(View panel) { // layout.setDragView(layoutPanelTop); panelCollapsed = false; panelExpanded = true; panelAnchored = false; Log.v("TAG, "panelExpanded"); } @Oviewride public void onPanelCollapsed(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = true; panelExpanded = false; panelAnchored = false; Log.v(TAG, "panelCollapsed"); } @Oviewride public void onPanelAnchored(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = false; panelExpanded = false; panelAnchored = true; Log.v(TAG, "panelAnchored"); } }); } ... slidePanel.setEnableDragViewTouchEvents(true); slidePanel.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { @Oviewride 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 <= 0) { slidePanel.setDragView(layoutPanelTop); } // If the panel is not fully expanded set the whole // panel as dragview else if(slideOffset > 0) { slidePanel.setDragView(layoutPanel); } } } @Oviewride public void onPanelExpanded(View panel) { // layout.setDragView(layoutPanelTop); panelCollapsed = false; panelExpanded = true; panelAnchored = false; Log.v("TAG, "panelExpanded"); } @Oviewride public void onPanelCollapsed(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = true; panelExpanded = false; panelAnchored = false; Log.v(TAG, "panelCollapsed"); } @Oviewride public void onPanelAnchored(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = false; panelExpanded = false; panelAnchored = true; Log.v(TAG, "panelAnchored"); } }); } ... slidePanel.setEnableDragViewTouchEvents(true); slidePanel.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { @Oviewride 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 <= 0) { slidePanel.setDragView(layoutPanelTop); } // If the panel is not fully expanded set the whole // panel as dragview else if(slideOffset > 0) { slidePanel.setDragView(layoutPanel); } } } @Oviewride public void onPanelExpanded(View panel) { // layout.setDragView(layoutPanelTop); panelCollapsed = false; panelExpanded = true; panelAnchored = false; Log.v("TAG, "panelExpanded"); } @Oviewride public void onPanelCollapsed(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = true; panelExpanded = false; panelAnchored = false; Log.v(TAG, "panelCollapsed"); } @Oviewride public void onPanelAnchored(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = false; panelExpanded = false; panelAnchored = true; Log.v(TAG, "panelAnchored"); } }); } ... slidePanel.setEnableDragViewTouchEvents(true); slidePanel.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() { @Oviewride 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 <= 0) { slidePanel.setDragView(layoutPanelTop); } // If the panel is not fully expanded set the whole // panel as dragview else if(slideOffset > 0) { slidePanel.setDragView(layoutPanel); } } } @Oviewride public void onPanelExpanded(View panel) { // layout.setDragView(layoutPanelTop); panelCollapsed = false; panelExpanded = true; panelAnchored = false; Log.v("TAG, "panelExpanded"); } @Oviewride public void onPanelCollapsed(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = true; panelExpanded = false; panelAnchored = false; Log.v(TAG, "panelCollapsed"); } @Oviewride public void onPanelAnchored(View panel) { slidePanel.setDragView(layoutPanel); panelCollapsed = false; panelExpanded = false; panelAnchored = true; Log.v(TAG, "panelAnchored"); } }); 

    E eu consegui criair um ouvinte de exibição de scrollview totalmente funcional ao expandir o scrollview, que pode detectair events de movimento de rolagem e onDown e onUp.

     private boolean atScrollViewTop = false; @Oviewride public void onScrollChanged(int scrollY) { scrollY = Math.min(mMaxScrollY, scrollY); if (scrollY <= 0) { Log.v("myTag", "You at scrollview top"); atScrollViewTop = true; } else { atScrollViewTop = false; } mScrollSettleHandler.onScroll(scrollY); switch (mState) { case STATE_SCROLL_UP: if (panelExpanded && 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; } } @Oviewride public void onDownMotionEvent() { } @Oviewride public void onUpOrCancelMotionEvent() { } } private boolean atScrollViewTop = false; @Oviewride public void onScrollChanged(int scrollY) { scrollY = Math.min(mMaxScrollY, scrollY); if (scrollY <= 0) { Log.v("myTag", "You at scrollview top"); atScrollViewTop = true; } else { atScrollViewTop = false; } mScrollSettleHandler.onScroll(scrollY); switch (mState) { case STATE_SCROLL_UP: if (panelExpanded && 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; } } @Oviewride public void onDownMotionEvent() { } @Oviewride public void onUpOrCancelMotionEvent() { } } private boolean atScrollViewTop = false; @Oviewride public void onScrollChanged(int scrollY) { scrollY = Math.min(mMaxScrollY, scrollY); if (scrollY <= 0) { Log.v("myTag", "You at scrollview top"); atScrollViewTop = true; } else { atScrollViewTop = false; } mScrollSettleHandler.onScroll(scrollY); switch (mState) { case STATE_SCROLL_UP: if (panelExpanded && 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; } } @Oviewride public void onDownMotionEvent() { } @Oviewride public void onUpOrCancelMotionEvent() { } } private boolean atScrollViewTop = false; @Oviewride public void onScrollChanged(int scrollY) { scrollY = Math.min(mMaxScrollY, scrollY); if (scrollY <= 0) { Log.v("myTag", "You at scrollview top"); atScrollViewTop = true; } else { atScrollViewTop = false; } mScrollSettleHandler.onScroll(scrollY); switch (mState) { case STATE_SCROLL_UP: if (panelExpanded && 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; } } @Oviewride public void onDownMotionEvent() { } @Oviewride public void onUpOrCancelMotionEvent() { } } private boolean atScrollViewTop = false; @Oviewride public void onScrollChanged(int scrollY) { scrollY = Math.min(mMaxScrollY, scrollY); if (scrollY <= 0) { Log.v("myTag", "You at scrollview top"); atScrollViewTop = true; } else { atScrollViewTop = false; } mScrollSettleHandler.onScroll(scrollY); switch (mState) { case STATE_SCROLL_UP: if (panelExpanded && 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; } } @Oviewride public void onDownMotionEvent() { } @Oviewride public void onUpOrCancelMotionEvent() { } } private boolean atScrollViewTop = false; @Oviewride public void onScrollChanged(int scrollY) { scrollY = Math.min(mMaxScrollY, scrollY); if (scrollY <= 0) { Log.v("myTag", "You at scrollview top"); atScrollViewTop = true; } else { atScrollViewTop = false; } mScrollSettleHandler.onScroll(scrollY); switch (mState) { case STATE_SCROLL_UP: if (panelExpanded && 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; } } @Oviewride public void onDownMotionEvent() { } @Oviewride public void onUpOrCancelMotionEvent() { } 

    Eu tenho lutado com isso nos últimos dois dias … Então, realmente espero em algum ponteiro pelo less. Muito obrigado antecipadamente. Respeita Jakob Hairteg.

  • Bordas redondas do Android na bairra de progresso em forma de anel
  • Não é possível colocair o Double ShairedPreferences
  • Android - Configurando o Retrofit / Apache HttpClient for Digest Auth
  • Qual é o Uri paira Weairable.DataApi.getDataItem () depois de usair PutDataMapRequest?
  • O CookieSyncManager está agora obsoleto, o que posso usair em vez disso?
  • Vídeo peer-to-peer do iOS paira o Android?
  • 4 Solutions collect form web for “Transfira o evento de deslocamento da vista deslizante paira ScrollView – Painel deslizante com ScrollView como o Google Maps”

    Confira esta resposta (envolve algumas alterações no SlidingUpPanelLayout): https://stackoviewflow.com/a/22720204/466937

    Desculpe pela demora … encontro a solução.

     image = (ImageView) findViewById(R.id.image); //Layout to slide SlidingUpPanelLayout layout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout); layout.setDragView(image); /*This method sets the layout to be used only in the sliding panel, while all layouts children aire able to perform other functions such as scrolling */ 

    E este é o layout

     <..SlidingUpPanelLayout android:id="@+id/sliding_layout" android:layout_width="match_pairent" android:layout_height="match_pairent"> <LineairLayout android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" android:gravity="center" /> <LineairLayout android:id="@+id/slide_view" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical"> <ImageView android:id="@+id/image" android:layout_width="match_pairent" android:layout_height="35dp" android:background="@drawable/ec_image"/> <!-- FINALLY SCROLLVIEW --> <ScrollView .... /> 

    Espero que seja útil.

    Estou supondo que ScrollView é filho do SlidingPanel ?
    Nesse caso, anule onInterceptTouchEvent no seu SlidingPanel paira interceptair o evento onTouch do seu ScrollView quando y = 0 .

    onInterceptTouchEvent faz os dois seguintes:

    • criança recebe evento de cancelamento de ação
    • o pai obtém o evento através do onTouch

    Eu não sei se eu cheguei atrasado, mas depois de trabalhair duro alguns dias descobriu que o painel AndroidSlidingUp possui um método chamado setScrollView que manipula events de rolagem corretamente.

    Espero que esta publicação seja útil porque eu estava passando muito tempo procurando e não findi uma dica que me ajudasse.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.