From fb1f3c2cd8287b20433768367031bd4ba4e9acd6 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Sat, 8 May 2021 16:42:57 +0900 Subject: [PATCH] Due to MotionLayout, the bottom nav bar won't hide on scroll. Instead give recyclerview bottom padding to avoid last row/item being partly hidden. --- .../CustomHideBottomViewOnScrollBehavior.java | 17 ++++++++++++++++- app/src/main/res/layout/fragment_discover.xml | 3 +++ app/src/main/res/layout/fragment_feed.xml | 2 +- app/src/main/res/layout/fragment_hashtag.xml | 5 +++-- app/src/main/res/layout/fragment_location.xml | 5 +++-- app/src/main/res/layout/fragment_profile.xml | 3 ++- 6 files changed, 28 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/customviews/helpers/CustomHideBottomViewOnScrollBehavior.java b/app/src/main/java/awais/instagrabber/customviews/helpers/CustomHideBottomViewOnScrollBehavior.java index 765fc679..dabc622b 100644 --- a/app/src/main/java/awais/instagrabber/customviews/helpers/CustomHideBottomViewOnScrollBehavior.java +++ b/app/src/main/java/awais/instagrabber/customviews/helpers/CustomHideBottomViewOnScrollBehavior.java @@ -1,5 +1,7 @@ package awais.instagrabber.customviews.helpers; +import android.content.Context; +import android.util.AttributeSet; import android.view.View; import androidx.annotation.NonNull; @@ -12,6 +14,13 @@ import com.google.android.material.bottomnavigation.BottomNavigationView; public class CustomHideBottomViewOnScrollBehavior extends HideBottomViewOnScrollBehavior { private static final String TAG = "CustomHideBottomView"; + public CustomHideBottomViewOnScrollBehavior() { + } + + public CustomHideBottomViewOnScrollBehavior(final Context context, final AttributeSet attrs) { + super(context, attrs); + } + @Override public boolean onStartNestedScroll(@NonNull final CoordinatorLayout coordinatorLayout, @NonNull final BottomNavigationView child, @@ -23,7 +32,13 @@ public class CustomHideBottomViewOnScrollBehavior extends HideBottomViewOnScroll } @Override - public void onNestedPreScroll(@NonNull final CoordinatorLayout coordinatorLayout, @NonNull final BottomNavigationView child, @NonNull final View target, final int dx, final int dy, @NonNull final int[] consumed, final int type) { + public void onNestedPreScroll(@NonNull final CoordinatorLayout coordinatorLayout, + @NonNull final BottomNavigationView child, + @NonNull final View target, + final int dx, + final int dy, + @NonNull final int[] consumed, + final int type) { if (dy > 0) { slideDown(child); } else if (dy < 0) { diff --git a/app/src/main/res/layout/fragment_discover.xml b/app/src/main/res/layout/fragment_discover.xml index 6636e3bc..e18824c7 100644 --- a/app/src/main/res/layout/fragment_discover.xml +++ b/app/src/main/res/layout/fragment_discover.xml @@ -10,12 +10,15 @@ android:id="@+id/swipe_refresh_layout" android:layout_width="match_parent" android:layout_height="match_parent" + android:clipToPadding="false" + android:paddingBottom="?attr/actionBarSize" app:layout_behavior="@string/appbar_scrolling_view_behavior"> @@ -33,7 +34,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:clipToPadding="false" - android:paddingBottom="?attr/actionBarSize" tools:listitem="@layout/item_feed_grid" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_hashtag.xml b/app/src/main/res/layout/fragment_hashtag.xml index ad78e4c2..45cd6b01 100644 --- a/app/src/main/res/layout/fragment_hashtag.xml +++ b/app/src/main/res/layout/fragment_hashtag.xml @@ -18,6 +18,8 @@ android:id="@+id/swipe_refresh_layout" android:layout_width="match_parent" android:layout_height="0dp" + android:clipToPadding="false" + android:paddingBottom="?attr/actionBarSize" app:layout_behavior="@string/appbar_scrolling_view_behavior" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toBottomOf="@id/header"> @@ -26,7 +28,6 @@ android:id="@+id/posts" android:layout_width="match_parent" android:layout_height="match_parent" - android:clipToPadding="false" - android:paddingBottom="?attr/actionBarSize" /> + android:clipToPadding="false" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_location.xml b/app/src/main/res/layout/fragment_location.xml index 09f98c39..9293dc2a 100644 --- a/app/src/main/res/layout/fragment_location.xml +++ b/app/src/main/res/layout/fragment_location.xml @@ -18,6 +18,8 @@ android:id="@+id/swipe_refresh_layout" android:layout_width="match_parent" android:layout_height="0dp" + android:clipToPadding="false" + android:paddingBottom="?attr/actionBarSize" app:layout_behavior="@string/appbar_scrolling_view_behavior" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toBottomOf="@id/header"> @@ -26,7 +28,6 @@ android:id="@+id/posts" android:layout_width="match_parent" android:layout_height="match_parent" - android:clipToPadding="false" - android:paddingBottom="?attr/actionBarSize" /> + android:clipToPadding="false" /> \ No newline at end of file diff --git a/app/src/main/res/layout/fragment_profile.xml b/app/src/main/res/layout/fragment_profile.xml index efc1b3db..051dd0aa 100644 --- a/app/src/main/res/layout/fragment_profile.xml +++ b/app/src/main/res/layout/fragment_profile.xml @@ -19,6 +19,8 @@ android:id="@+id/swipe_refresh_layout" android:layout_width="match_parent" android:layout_height="0dp" + android:clipToPadding="false" + android:paddingBottom="?attr/actionBarSize" app:layout_behavior="@string/appbar_scrolling_view_behavior" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toBottomOf="@id/header"> @@ -28,7 +30,6 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:clipToPadding="false" - android:paddingBottom="?attr/actionBarSize" tools:listitem="@layout/item_feed_photo" />