Menu
Who Do Is
  • Home
  • What
  • How
  • Is
  • Can
  • Are
  • Does
  • Do
  • Why
  • Who
  • Where
  • Which
  • Which
  • Should
  • Will
  • When
  • What’s
  • Did
Who Do Is

[ANSWERED] android – How do I smoothly hide a view on RecyclerView scoll?

Posted on November 14, 2022

Solution 1 :

You can use YoYo library from github have all animation and very easy to use
https://github.com/daimajia/AndroidViewAnimations

You can use this any where

Simple use it inside onscrollchanged method of recyclerview

Problem :

I have a RecylcerView and a view which is above it and I want to hide it when I scroll down. I have found a way which kind of works, but it’s pretty janky and sometimes takes the speed out of the scrolling action. How do I make it more fluent?

Layout:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns_android="http://schemas.android.com/apk/res/android"
xmlns_app="http://schemas.android.com/apk/res-auto"
xmlns_tools="http://schemas.android.com/tools"
android_layout_width="match_parent"
android_layout_height="match_parent"
tools_context=".ui.Items.ItemsFragment">

<FrameLayout
    android_id="@+id/frameLayout"
    android_layout_width="match_parent"
    android_layout_height="0dp"
    android_layout_marginTop="8dp"
    app_layout_constraintBottom_toBottomOf="parent"
    app_layout_constraintEnd_toEndOf="parent"
    app_layout_constraintStart_toStartOf="parent"
    app_layout_constraintTop_toBottomOf="@+id/cardViewSearch">

    <androidx.recyclerview.widget.RecyclerView


        android_id="@+id/recylcerViewItems"
        android_layout_width="match_parent"
        android_layout_height="match_parent"
        android_divider="@android:color/transparent"
        android_dividerHeight="8dp"
        android_scrollbars="vertical"
        android_visibility="visible"
        app_layout_constraintBottom_toBottomOf="parent"
        app_layout_constraintEnd_toEndOf="parent"
        app_layout_constraintStart_toStartOf="parent"
        app_layout_constraintTop_toBottomOf="@+id/chipGroup" />

    <com.google.android.material.chip.ChipGroup
        android_id="@+id/chipGroup"
        android_layout_width="match_parent"
        android_layout_height="wrap_content"
        android_clipToPadding="false"
        android_padding="8dp"
        android_visibility="visible"
        app_layout_constraintEnd_toEndOf="parent"
        app_layout_constraintStart_toStartOf="parent"
        app_layout_constraintTop_toBottomOf="@+id/cardViewSearch">

        <com.google.android.material.chip.Chip
            android_id="@+id/toolsChip"
            style="@style/Widget.MaterialComponents.Chip.Action"
            android_layout_width="wrap_content"
            android_layout_height="wrap_content"
            android_elevation="4dp"
            android_fontFamily="@font/nunito_regular"
            android_text="@string/item_tools"
            android_textColor="@color/colorChipText"
            app_chipBackgroundColor="@color/colorChipTools"
            app_chipIcon="@drawable/ic_tool_black_24dp"
            app_chipIconTint="@color/colorChipText" />

        <com.google.android.material.chip.Chip
            android_id="@+id/blocksChip"
            style="@style/Widget.MaterialComponents.Chip.Action"
            android_layout_width="wrap_content"
            android_layout_height="wrap_content"
            android_elevation="4dp"
            android_fontFamily="@font/nunito_regular"
            android_text="@string/item_blocks"
            android_textColor="@color/colorChipText"
            app_chipBackgroundColor="@color/colorChipBlocks"
            app_chipIcon="@drawable/ic_block_black_24dp"
            app_chipIconTint="@color/colorChipText" />

    </com.google.android.material.chip.ChipGroup>

</FrameLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

I want to hide the ChipGroup. There are more Chips in the group, but I removed them here.

Hide Code right now:

    final ChipGroup chipGroup = (ChipGroup) root.findViewById(R.id.chipGroup);
    mRecyclerView.setPadding(0, chipGroup.getHeight(), 0,0);

    mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
            if(newState == RecyclerView.SCROLL_STATE_IDLE){
                if(!showFilteredResults) {
                    showFilteredResults = true;
                }
            } else {
                if(showFilteredResults) {
                    showFilteredResults = false;
                }
            }
            super.onScrollStateChanged(recyclerView, newState);
        }

        @Override
        public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
            FrameLayout frameLayout = (FrameLayout) root.findViewById(R.id.frameLayout);
            if (dy > 0 && HIDE_VIEWS_ON_SCOLL) {
                // scrolling up
                Log.i("scroll", "up");
                TransitionManager.beginDelayedTransition(frameLayout, new ChangeBounds());
                chipGroup.setVisibility(View.GONE);
                mRecyclerView.setPadding(0, 0,0,0);
            } else if (dy < 0 && HIDE_VIEWS_ON_SCOLL){
                // scrolling down
                Log.i("scroll", "down");
                TransitionManager.beginDelayedTransition(frameLayout, new ChangeBounds());
                chipGroup.setVisibility(View.VISIBLE);
                mRecyclerView.setPadding(0, chipGroup.getHeight(),0,0);
            }

            super.onScrolled(recyclerView, dx, dy);
        }
    });
READ  [ANSWERED] Call java function from python - Chaquopy
Powered by Inline Related Posts

Recent Posts

  • How can I play with my cat without toys?
  • What is a bag pipe band called?
  • Are Honda Civics actually fast?
  • Are Yankee candles toxic?
  • How do I pair my Michael Kors smartwatch with my Android?

Recent Comments

No comments to show.

Archives

  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuántas
  • ¿Cuánto
  • ¿Que
  • ¿Quién
  • 90” and 108” so you may have to round up to the nearest size.
  • and delete any Spotify folders from it. Once this is done
  • Android
  • Are
  • At
  • Bei
  • blink
  • C'est
  • Can
  • carbs
  • Comment
  • Did
  • Do
  • Does
  • During
  • For
  • Has
  • How
  • In
  • Is
  • Ist
  • Kann
  • Können
  • nouveau
  • On
  • or 108 inches.2020-08-03
  • Où
  • owning
  • Pourquoi
  • Puis-je
  • Quand
  • Quante
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • spiritual
  • tap the downward-facing arrow on the top left. A downward-facing arrow will appear underneath each song in the album; they'll turn green as the download completes.2020-07-28
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welcher
  • Welches
  • Welke
  • Wer
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Whose
  • Why
  • Wie
  • Will
  • Wo
  • Woher
  • you will receive two curtains each with the same measurements of width 66"" (168cm) x drop 54""(137cm).
  • you'll see a green downward-facing arrow next to each song.2021-02-26
©2023 Who Do Is | Powered by SuperbThemes & WordPress