-1

I have a RecyclerView in which list of CardView is added and there is an ImageButton when I over-scroll the list the content of list is overlap on button. CardView should be scroll before the ImageButton.

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/id1"
    style="@style/Style1">

    <ImageButton
        android:id="@+id/btn"
        style="@style/NoStyle"
        app:layout_constraintBottom_toBottomOf="@id/recycler_view"
        app:layout_constraintEnd_toStartOf="@id/recycler_view"
        app:layout_constraintHorizontal_bias="0.002"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="@id/recycler_view"
        app:layout_constraintWidth_percent="0.05" />

    <androidx.cardview.widget.CardView
        android:id="@+id/recycler_view"
        style="@style/NoStyle"
        android:background="@color/transparent"
        android:orientation="horizontal"
        app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHeight_percent="0.6"
        app:layout_constraintHorizontal_bias="0.1"
        app:layout_constraintStart_toEndOf="@id/btn"
        app:layout_constraintTop_toBottomOf="@parent"
        app:layout_constraintVertical_bias="0.1"
        app:layout_constraintWidth_percent="0.9"
        app:noOfColumnInFirstPage="3" />
</androidx.constraintlayout.widget.ConstraintLayout>

Currently, it is like this. I don't want it to overlap with my button, while maintaining my bounce effect. enter image description here

Div
  • 11
  • 3
  • Is this verbatim because the @ next to parent is wrong `app:layout_constraintTop_toBottomOf="@parent"` – avalerio May 26 '21 at 20:44
  • It is just a typo sorry `app:layout_constraintTop_toBottomOf="parent" ` – Div May 27 '21 at 12:20
  • Does the image button need to be on top of the CardView or on the bottom of it? – avalerio May 27 '21 at 12:45
  • Actually, both are horizontal. So, there is an image button first and then there is CardView. – Div May 27 '21 at 12:57
  • 1
    Android doesn't care what you want and this is the whole wrong XML. Using **bold** formatting is pretty useless, when you first speak of a `RecyclerView` and then post a `CardView`. What's the point? – Martin Zeitler May 29 '21 at 21:07
  • Sorry @MartinZeitler, I should be more specific about the issue. I have a RecyclerView to display a list of CardViews. – Div May 29 '21 at 22:36

1 Answers1

0

The image button is constrained to the end of the parent, not the start of the CardView.

This app:layout_constraintEnd_toEndOf="parent"

Should be this app:layout_constraintEnd_toStartOf="@id/recycler_view"

avalerio
  • 2,072
  • 1
  • 12
  • 11
  • It didn't work. I'm using bounce effect to my RecyclerView so, when I tries to over-scroll it overlaps with the button. – Div May 27 '21 at 13:13
  • By over scroll are you dragging if over the image button and its overlapping or are you swiping it and it momentarily goes over the Image button, or both can happen. – avalerio May 27 '21 at 14:14
  • It only overlaps when I try to drag list over the limit (when list reaches end). When I swipe threw pages it doesn't overlap. – Div May 27 '21 at 14:45
  • From what I can tell you are using the default LinearLayoutManager you may need to override is default behavior because you are adding the bounce effect. Try this https://stackoverflow.com/questions/41381621/how-to-disable-overscroll-effect-on-recyclerview-only-when-you-cant-scroll-anyw – avalerio May 27 '21 at 14:54
  • I have tried what you suggested but it will stopped when there are no more content which will remove the bounce effect. It helps in overlapping but I will not get bounce effect. – Div May 29 '21 at 21:04