Unable to use ScrollView layout inside SlidingUpPanelLayout Xamarin Android

I used this library in my code. Basically, I have a ScrollView on a SlidingUp panel layout. The code is as follows:

<cheesebaron.slidinguppanel.SlidingUpPanelLayout
                android:id="@+id/sliding_layout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="bottom">
                <android.support.v4.view.ViewPager
                    android:id="@+id/HomeFrameLayout"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />
                <ScrollView
                    android:id="@+id/slidingPanelScrollView"
                    android:layout_height="match_parent"
                    android:layout_width="match_parent"
                    android:background="@android:color/transparent"
                    android:clickable="true"
                    android:focusable="false">
                    <RelativeLayout
                        android:layout_height="match_parent"
                        android:layout_width="match_parent">
                        <RelativeLayout
                            android:id="@+id/cardHolderRelativeLayout"
                            android:layout_height="match_parent"
                            android:layout_width="380dp"
                            android:background="@android:color/transparent"
                            android:layout_centerHorizontal="true"
                            android:padding="10dp">
                            <LinearLayout
                                android:id="@+id/linearLayout1"
                                android:layout_height="250dp"
                                android:layout_width="match_parent"
                                android:background="#FF0000"
                                android:layout_marginBottom="15dp" />
                            <LinearLayout
                                android:id="@+id/linearLayout2"
                                android:layout_height="250dp"
                                android:layout_width="match_parent"
                                android:background="#00FF00"
                                android:layout_marginBottom="15dp"
                                android:layout_below="@id/linearLayout1" />
                            <LinearLayout
                                android:id="@+id/linearLayout3"
                                android:layout_height="250dp"
                                android:layout_width="match_parent"
                                android:background="#0000FF"
                                android:layout_marginBottom="15dp"
                                android:layout_below="@id/linearLayout2" />
                            <LinearLayout
                                android:id="@+id/linearLayout4"
                                android:layout_height="250dp"
                                android:layout_width="match_parent"
                                android:background="#0000FF"
                                android:layout_marginBottom="15dp"
                                android:layout_below="@id/linearLayout2" />
                        </RelativeLayout>
                    </RelativeLayout>
                </ScrollView>
            </cheesebaron.slidinguppanel.SlidingUpPanelLayout>

I want to ensure that if the SlidingUpPanelLayout is expanded, the user will have to scroll through the ScrollView. If ScrollView scrolls up (the user scrolls down on his phone) and the user continues to scroll down, SlidingUpPanelLayout should crash.

I am implementing the following code:

_slidingUpPanelLayout.NestedScrollingEnabled = true;

        _scrollView.ViewTreeObserver.ScrollChanged += (sender, e) => 
        {
            var y = _scrollView.ScrollY;
            if (y < -20)
            {
                _slidingUpPanelLayout.SlidingEnabled = true;
            } 

        };

        _slidingUpPanelLayout.PanelExpanded += (sender, args) => 
        {
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MatchParent, RelativeLayout.LayoutParams.MatchParent);
            _cardHolderRelativeLayout.LayoutParameters = layoutParams;

            _slidingUpPanelLayout.SlidingEnabled = false;
        };

Basically, I set SlidingEnable to true / false to change the scroll event listener.

However, the problem is with ScrollView. It only starts when scrolling through a ScrollView and then scrolling down.

, , - . ? , AndroidSlidingUpPanel Android, , ScrollView SlidingUpPanelLayout. , .

, - NestedScrollingEnabled = true SlidingUp , Stackoverflow.

,

+6
1

nestedScrollview scrollview

NestedScrollView scrollView = (NestedScrollView) findViewById (R.id.scrollView);
scrollView.setFillViewport (true);
-1

Source: https://habr.com/ru/post/1016805/


All Articles