bignerdranch / expandable-recycler-view

[DEPRECATED]
MIT License
1.21k stars 292 forks source link

Expanding does not respect item decoration #197

Open dasheck0 opened 8 years ago

dasheck0 commented 8 years ago

Hi,

when adding an item decoration like a simple line and expanding a parent by clicking it the item decoration does not get updated. It seems that the child item also gets an item decoration which is drawn but not animated. Here is the code for my decoration

public class SimpleLineDividerItemDecoration extends RecyclerView.ItemDecoration {

  private Drawable lineDivider;

  public SimpleLineDividerItemDecoration(Context context) {
    lineDivider = ContextCompat.getDrawable(context, R.drawable.line_divider);
  }

  @Override public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
    int left = parent.getPaddingLeft();
    int right = parent.getWidth() - parent.getPaddingRight();

    for (int i = 0; i < parent.getChildCount(); i++) {
      drawItemDecoration(parent.getChildAt(i), lineDivider, left, right, c);
    }
  }

  private void drawItemDecoration(View view, Drawable decoration, int leftPadding, int rightPadding, Canvas canvas) {
    RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams();

    int top = view.getBottom() + params.bottomMargin;
    int bottom = top + decoration.getIntrinsicHeight();

    decoration.setBounds(leftPadding, top, rightPadding, bottom);
    decoration.draw(canvas);
  }
}

best regards dasheck

EDIT:

This is really hard to explain, therefor it would be necessary to create a little project to see the project for yourself. Thanks in advance for any feedback.

zeroarst commented 8 years ago

Exactly have the same issue. The decoration is not animated along with item views.

dgreenhalgh commented 7 years ago

In Expandable RecyclerView's current state, you should have enough information to manually update your ItemDecoration on expansion. This could be a bit of a pain depending on the complexity of your implementation, so we've started to discuss what improved ItemDecoration support would look in Expandable RecyclerView. Look for more information in a future release.