Open sergiiz opened 9 years ago
Hi there! I managed to get something you want with this code:
weekView.post(new Runnable() {
@Override
public void run() {
int height = weekView.getHeight();
int textSize = weekView.getTextSize();
int padding = weekView.getHeaderRowPadding();
height = height - textSize - (2 * padding);
weekView.setHourHeight(height / 24);
}
});
Note that as I tested it only works in activity's onCreate()
method. I wanted to ultimately use it in a fragment, but I always get exceptions because I call getHeight()
sooner than it is measured gettint a negative size. Also note thate it will still support scrolling, therefore it will be a bit jumpy when it recognizes vertical scroll.
But I also would really love to have this feature built in.
Edit: for clarification; my code is nowhere near a perfect solution
@sergiiz What if you set the hourheight to 0 or 1 or so? I think (at least in the new version that will be out soon, that should work, but I haven't tested it yet).
In the current version, zooming is possible so this issue is partially solved. @caske33 did you realize that when you are fully zoomed out, you can still scroll up-down a little bit? Is there an easy fix for that?
I'm guessing the calculation is then wrong and we need to fix that. (We might have missed a padding or something).
The library is rather simple so it should be simpel to get into it. Feel free to fix this and sent over a Pull Request. I'll be happy to merge it :)
Is it possible to scale calendar day height to make all 24 hours to fit the screen? Or even better, to make only business hours fit the screen?
Now I found the way how to do it if set proper height of each hour like in xml: app:hourHeight="20dp", but obviously it is a hardcode approach which can't be applied for all devices screen sizes