Recyclerview keeps the layout always expanded
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.
I got the same issue. is this fixed or do you have alternative way?
I got the same issue. is this fixed or do you have alternative way?
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...