google / blockly-android

Blockly for Android
Apache License 2.0
672 stars 209 forks source link

Horizontal Toolbox Changes Height as You Scroll #739

Closed TheBrokenRail closed 5 years ago

TheBrokenRail commented 5 years ago

Expected Behavior

The toolbox is the height of the tallest block in the category or has a fixed height.

Actual Behavior

It changes height when you scroll and sometimes doesn't change back when you scroll back.

Additional Information

The GIF uses my app's code but it is the same in the "Blockly Flyouts" demo, it is just more noticeable in my setup.

GIF Example

untitled

AnmAtAnm commented 5 years ago

Thanks for the animation demonstrating the problem. I'm surprised the height does not bounce back when you scroll back.

Fixing this would require measuring all block group views to find the highest, and setting that as the height of the toolbox. However, the toolbox is really a RecyclerView, and the block group views are created on demand. Currently, there is no way to measure (or estimate) the height without creating the view.

Relatedly, there should probably also be a constraint to the max height of such a toolbox. Maybe not more than 60% of the work area?

TheBrokenRail commented 5 years ago

Without that many blocks in the toolbox would it hurt performance that much to disable recycling views on the toolbox and shouldn't there also be a minimum height of the toolbox?

AnmAtAnm commented 5 years ago

Replacing the recycler view for a small number of blocks (<20?) is a very reasonable approach. Having two paths does complicate testing.

And yes, the toolbox should have a minimum size (height if on the top or bottom, width otherwise).