ExpandableLayout icon indicating copy to clipboard operation
ExpandableLayout copied to clipboard

Recyclerview keeps the layout always expanded

Open razon30 opened this issue 8 years ago • 3 comments

The recyclerview Item

 `  <com.github.aakira.expandablelayout.ExpandableLinearLayout
            android:id="@+id/expandableLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            app:ael_duration="100"
            app:ael_expanded="false">

        <techfie.razon.banglashahittobcsjob.MyTextView
            android:id="@+id/wordTwo"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/gradient5"
            android:padding="4dp"
            android:text="২য় শব্দ "
            android:textColor="#FFFFFF"
            android:textSize="16sp" />
        </com.github.aakira.expandablelayout.ExpandableLinearLayout>`

The adapter

` @Override public void onBindViewHolder(final AdapterExamDetails.ViewHolderAdapterRecycler holder, int position) {

    holder.setIsRecyclable(false);
    holder.expandLayout.setInRecyclerView(true);

    holder.qsn.setText(questionList.get(position).getString());
    holder.ans.setText(answereList.get(position).getString());

    if (holder.expandLayout.isExpanded()){
        holder.expandLayout.toggle();
    }

    holder.btnToggle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            holder.expandLayout.toggle();
            if (holder.expandLayout.isExpanded()){
                holder.btnToggle.setImageResource(R.drawable.down_arrow);
            }else {
                holder.btnToggle.setImageResource(R.drawable.arrow_up);
            }
        }
    });

}`

Please give solution. You should response in this regards immediately. Please.

razon30 avatar Jun 16 '17 15:06 razon30

I got the same issue. is this fixed or do you have alternative way?

washswat avatar Nov 21 '17 09:11 washswat

I got the same issue. is this fixed or do you have alternative way?

siavash-sajjad avatar Jan 15 '18 13:01 siavash-sajjad

It seems that switching to ExpandableRelativeLayout solved this issue for me.

    <com.github.aakira.expandablelayout.ExpandableRelativeLayout
        android:id="@+id/expandable_layout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="12dp"
        app:ael_expanded="false">

        <TextView
            android:id="@+id/secondary_facilities"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </com.github.aakira.expandablelayout.ExpandableRelativeLayout>

Not quite sure why the LinearLayout version doesn't work, but this seems to do the trick for now.

Forgot the second part of this: you need to call collapse on the onBindViewHolder like so holder.expandableLayout.collapse();

I'm not sure if that is the correct spot to put the collapse, but my RecyclerView was short and static, so I was able to set a fixed size on it.

This seemed to get my desired result, but your mileage may very. It's annoying that the ael_expanded isn't respected in layouts for RecyclerView items...

kwelsh avatar Mar 10 '18 07:03 kwelsh