Fighting android canvas – Hexagonal imageview layout for Android
We made a simple design for one of our apps which included a hexagonal network of images which should contain profile pictures of the users who liked a certain app.
So we wanted to have something like this:
To achieve it after many research we found this:
Which is a google java engine for using hexagonal layout. There aren’t many alternatives and the ones we found like https://github.com/riotopsys/Hexgrid were suspected to have memory leaks. So using this hex engine we found that on OS versions prior Android 4.0 everything was fine. But on 4.0+ the canvas added additional padding at the bottom of the view. So it looked something like this:
We spent hours on this until we discovered the OS problem.. So as it says here there were some new things from version 14 and above in the canvas which you can check HERE.
To fix this issue we had to do the simplest thing – disable the hardware acceleration for the specific view. You can check the ways to disable it HERE.
After disabling it everything is perfect! If anyone is interested the issue is HERE. Feel free to use the library. It’s great!