Consider eliminating potentially redundant views
See original GitHub issueGreat work so far! I really appreciate you putting this together!
I was playing around with the layout inspector and sample app and was surprised to see how deeply nested the view hierarchy is and how many extra views are being generated.
I believe the library is making too many FrameLayouts
that are unnecessary in some situations and at least one LinearLayout
that, as far as I can tell, can be eliminated completely without any impact to users.
Removing the extra LinearLayout
, if possible, would be a quick and easy win.
Here’s the block that creates it inside CalendarAdapter.onCreateViewHolder
:
val monthBodyLayout = LinearLayout(context).apply {
layoutParams = LinearLayout.LayoutParams(LP.WRAP_CONTENT, LP.WRAP_CONTENT)
orientation = LinearLayout.VERTICAL
id = bodyViewId
}
rootLayout.addView(monthBodyLayout)
If you remove the block above and make some other minor adjustments, the week views can be added directly to the rootLayout
.
Removal of the extra FrameLayout
s looks to be a little more tricky and I’d like to understand more about why it’s there. However, if I understand what you’re trying to do, I think there may be some better alternatives that accomplish what you’re looking for.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
Thought this would be closed since it’s referenced in #186 but just remembered it’s only for merges on the main branch. So closing this manually.
I think I’ve done it 🙂 . I’ve managed to get rid of the
FrameLayout
without any impact to the user (as far as I can tell). All the calendars look the same and all the tests pass. PR incoming.