cachapa / ExpandableLayout

An expandable layout container for Android
Apache License 2.0
2.34k stars 273 forks source link

Child view in fragment is partially cut when the screen height is low #74

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hi, I have an issue and I hope you can help me. My app is using your library for collapsing/expanding the horizontal RecyclerView, which is in a Fragment, but items in RecyclerView were cut content (I don't know it is cut or compressed). This problem only occurs when my application is built on a device of 720x1280 size. When running with a larger size like 1440x2880, this problem does not occur. Note, this problem occurs with content view of Fragment, while Activity is not (no matter which size), because I use your library on Activity for the same layout. And finally, please forgive me because my English is not very good. Thank you so much.

cachapa commented 5 years ago

Hi, sorry but there's not enough information in the screenshots to be able to figure out what the problem is. You could try removing ExpandableLayout to see if the problem is being caused by it.

cachapa commented 5 years ago

It seems to be related to how you're setting the height. ExpandableLayout works best when the size of the children is fixed. Is your parent recycler view set to wrap_content? That might cause the issue.

ghost commented 5 years ago

Please forgive me for deleting my own comment here, because I post a apart of UI that I have not been allowed from my boss (this app is not yet published). Yeah, I set wrap_content

<net.cachapa.expandablelayout.ExpandableLayout
                    android:id="@+id/expandable_layout_am_invoices"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    app:el_duration="@android:integer/config_mediumAnimTime"
                    app:el_expanded="false"
                    app:el_parallax="0.5">

                    <android.support.v7.widget.RecyclerView
                        android:id="@+id/rv_am_invoices"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:clipChildren="false"
                        android:clipToPadding="false"
                        android:nestedScrollingEnabled="false"
                        android:paddingLeft="8dp"
                        android:paddingRight="8dp"></android.support.v7.widget.RecyclerView>
                </net.cachapa.expandablelayout.ExpandableLayout>

But I don't understand a reason, why the Activity does not have this issue, the code is same

cachapa commented 5 years ago

I meant the parent recycler view. Also, having a recycler view inside Expandable layout maynot be the best way to solve what you have since it might cause the recycler view to misjudge its own size.

ghost commented 5 years ago

You mean I should have a layout (such as LinearLayout) which contains recyclerview and that layout inside expandablelayout? Or I should set fixed size for parent layout of recyclerview?

cachapa commented 5 years ago

I mean putting a recyclerview inside the expandable layout is a bad idea because recyclerview sizes its children asynchronously. You're essentially asking the recyclerview to size it's children while it's collapsed and hidden.

Nesting recyclerviews is a bad idea anyway for performance reasons.

ghost commented 5 years ago

So what should I do to get that animation. I want ExpandableLayout to expanded/collapsed a list of CardView items, maybe not use RecyclerView. Or I should set height for RecyclerView? You can recommend me a solution?

cachapa commented 5 years ago

If you use a regular linearlayout instead of a recyclerview it should work fine

ghost commented 5 years ago

Thank you. Now, let me try.

ghost commented 5 years ago

Hi, I think the issue was solved, my team agreed that the plan is to keep the child Views size fixed. Expanded / collapsed animation in your ExpandableLayout is so smooth. Thank you so much.

cachapa commented 5 years ago

np, happy you were able to fix it