android / views-widgets-samples

Multiple samples showing the best practices in views-widgets on Android.
Apache License 2.0
5.05k stars 3.01k forks source link

androidx.core.widget.NestedScrollView is not scrolling #14

Closed DilipSinghPanwar closed 4 years ago

DilipSinghPanwar commented 5 years ago

<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/background_light" android:fitsSystemWindows="false">

<androidx.core.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/background_screens"
    android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

            <LinearLayout
                android:id="@+id/appbarlayout"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="@color/colorSearchBackground"
                android:orientation="vertical">

                <RelativeLayout
                    android:id="@+id/activity_main"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginBottom="@dimen/margin_10"
                    android:background="@color/colorSearchBackground">

                    <bike.grup.riderapp.utils.CutLayout
                        android:id="@+id/diagonalLayout"
                        android:layout_width="match_parent"
                        android:layout_height="@dimen/_215sdp"
                        android:layout_alignParentStart="true"
                        android:layout_alignParentTop="true">

                        <ImageView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:background="#d4b6b6b6"
                            android:scaleType="centerCrop"
                            app:srcCompat="@drawable/placeholder" />

                    </bike.grup.riderapp.utils.CutLayout>

                    <de.hdodenhof.circleimageview.CircleImageView
                        android:id="@+id/avatar2"
                        android:layout_width="@dimen/_90sdp"
                        android:layout_height="@dimen/_90sdp"
                        android:layout_centerHorizontal="true"
                        android:layout_marginTop="@dimen/_130sdp"
                        android:layout_marginEnd="10dp"
                        android:layout_marginBottom="15dp"
                        android:padding="10dp"
                        android:src="@drawable/feed_profile_image" />

                    <TextView
                        android:id="@+id/title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/avatar2"
                        android:layout_centerHorizontal="true"
                        android:layout_gravity="center|center_vertical"
                        android:layout_marginStart="@dimen/margin_20"
                        android:layout_marginTop="-10dp"
                        android:layout_marginEnd="@dimen/margin_20"
                        android:fontFamily="@font/montserrat_semibold"
                        android:gravity="center_vertical|center"
                        android:padding="5dp"
                        android:text="HOG Baharien Chapter"
                        android:textAllCaps="false"
                        android:textColor="@color/colorPrimary"
                        android:textSize="15sp"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/subtitle"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/title"
                        android:layout_centerHorizontal="true"
                        android:layout_gravity="center|center_vertical"
                        android:layout_marginStart="@dimen/margin_20"
                        android:layout_marginTop="3dp"
                        android:layout_marginEnd="@dimen/margin_20"
                        android:fontFamily="@font/montserrat_regular"
                        android:gravity="center_vertical|center"
                        android:text="Bahrains Official Harley Davision Riding Club"
                        android:textAllCaps="false"
                        android:textColor="#767676"
                        android:textSize="13sp" />

                </RelativeLayout>

            </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <com.google.android.material.tabs.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="@dimen/_40sdp"
                android:background="@color/colorSearchBackground"
                app:tabGravity="fill"
                app:tabIndicatorColor="#000000"
                app:tabMode="fixed"
                app:tabTextAppearance="@style/MineCustomTabText"
                app:tabTextColor="#000000" />

            <bike.grup.riderapp.utils.NonSwipeableViewPager
                android:id="@+id/viewpager"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

        </LinearLayout>

    </LinearLayout>

</androidx.core.widget.NestedScrollView>

MickaelRomaniello commented 5 years ago

Have you fixed this issue? @DilipSinghPanwar cause I have the same.

Tried with: implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

and

implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1'

And this also because I know that there was an issue with it before.

Anyone knows how to fix it ?

lainguyen92 commented 5 years ago

I got same issue. Anyone can help?

MickaelRomaniello commented 5 years ago

Hello, so I fiexed it like this:

NestedScrollView with: android:clipToPadding="true" android:fillViewport="true" android:fitsSystemWindows="true"

Inside constraint layout: <androidx.constraintlayout.widget.ConstraintLayout android:id="@+id/constraint" android:layout_width="match_parent" android:layout_height="wrap_content">

RecyclerView inside of ConstraintLayout <androidx.recyclerview.widget.RecyclerView android:id="@+id/recyclerView" android:layout_width="match_parent" android:layout_height="0dp" android:background="@color/colorWhite" android:layout_marginTop="8dp" app:layout_constraintBottom_toBottomOf="@+id/constraint" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/viewInTopOfRecycler" />

I did it like this and using this version of gradle.

implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha4'

Hope it is useful!

fc9734ygn commented 4 years ago

I don't think you should set the android:layout_height of NestedScrollView child to match_parent it should be wrap_content

raghunandankavi2010 commented 3 years ago

Any update on this?