0

I have a Bottomsheet (with a recyclerview) with collapsed peekheight = 35 px where a small imageview is placed. After dismissing in the recyclerivew the position of this imageview is changed (from 42 px -> 80 px) and I didn't found the reason and any solution for this move.

Interessting aspect: Changing App-Theme to fullscreen, the problem doesn't appear. So it could also be a bug.

So i catch the Imageview position (getTop() -> 42) and set the catched position after the dismiss - code.

Unfortunately this does not work.

ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) bottomSheet.getChildAt(0).getLayoutParams();
params.setMargins(0,8,0,0);
bottomSheet.getChildAt(0).setLayoutParams(params);
bottomSheet.getChildAt(0).requestLayout();

The code works, but after dismiss the Imageview changes its position and that wrong position is not changeable.

Seems, that the Snackbar ist the reason for my (dismiss) problem.

RecyclerView recyclerView = findViewById(R.id.recycler_view);
Snackbar snackbar = Snackbar
          .make(recyclerView, "remove", Snackbar.LENGTH_SHORT);

I think the RecyclerView is the correct view for the snackbar, I tried also the bottomsheet-view. But the problem still exists.

Thanks for helping me GGK

  • Does your bottomSheet contain a ConstraintLayout? ConstraintLayouts are iffy if you don't use them right. Consider using something else that fits your needs, like a LinearLayout. – IcedLance Jul 19 '19 at 08:53
  • yes...a constraintLayout. But with a Imageview and the recyclerview...thats all. – GGK stands for Ukraine Jul 19 '19 at 09:00
  • Depending on the way it's set up ConstraintLayout ties layout of its children to each other which means changes in layout of one may cause changes in layout of other. That is why it is very easy to make a mistake with it. It is responsible for more than half of layout issues here on SO. And if all you have is 2 Views in it, you're better off using something lighter, but since you did not provide any related code no one can identify what exactly your issue is. – IcedLance Jul 19 '19 at 09:06
  • I have changed the constraintLayout -> LinearLayout - Problem persists. But I found the real reason -> the snackbar. Update OP – GGK stands for Ukraine Jul 19 '19 at 09:37

0 Answers0