TonicArtos / SuperSLiM

A layout manager for the RecyclerView with interchangeable linear, grid, and staggered displays of views, all with configurable section headers including the sticky variety as specified in the material design docs.
http://tonicartos.nz
2.12k stars 297 forks source link

headerDisplay doesn't work whatever. #170

Closed bytebeats closed 7 years ago

bytebeats commented 8 years ago

There is my header layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:id="@+id/rl_item_title"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/z_activity_bg"
    android:orientation="horizontal"
    android:paddingBottom="@dimen/margin_5"
    android:paddingTop="@dimen/margin_5"
    app:slm_headerDisplay="inline|sticky"
    app:slm_isHeader="true">
    <TextView
        android:id="@+id/tv_item_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="@dimen/margin_15"
        android:textColor="@color/e_hint"
        android:textSize="@dimen/font_15"
        tools:text="Title" />
    <TextView
        android:id="@+id/tv_item_title_desc"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:layout_marginRight="@dimen/margin_15"
        android:text=""
        android:textColor="@color/e_hint"
        android:textSize="@dimen/font_13"
        tools:text="Description" />
</RelativeLayout>

And I added app:slm_headerDisplay="inline|sticky" and app:slm_isHeader="true" explicitly. Meanwhile, on method onBindViewHolder, codes below were added just like the example did:

final GridSLM.LayoutParams layoutParams = GridSLM.LayoutParams.from(holder.itemView.getLayoutParams());
        if (viewType == TYPE_GROUP) {
            layoutParams.headerDisplay = GridSLM.LayoutParams.HEADER_STICKY & GridSLM.LayoutParams.HEADER_INLINE;
            if (layoutParams.isHeaderInline() || !layoutParams.isHeaderOverlay()) {
                layoutParams.width = ViewGroup.LayoutParams.MATCH_PARENT;
            } else {
                layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
            }
//            layoutParams.headerEndMarginIsAuto = false;
//            layoutParams.headerStartMarginIsAuto = false;
        }
        layoutParams.setSlm(LinearSLM.ID);
        layoutParams.setColumnWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        layoutParams.setFirstPosition(product.sectionFirstPosition);
        holder.itemView.setLayoutParams(layoutParams);

Every thing works well except for the header. So, what did I do wrong or what should I do?

khajievN commented 8 years ago

I have also this issue please can someone solve this issue