Zoom on weekView
Hi,
I'd like to know if there is a way to zoom/pinch on a week view ? And is it possible to display only days from Monday to Friday ?
Thank you
I don't think it has this feature implemented, but it should be not that hard. You will need to modify it to grab the pinch gesture and changes the "noOfVisibleDays" variable. Also, to set the days to just display monday to friday u set "noOfVisibleDays" to 5 and "firstDayOfWeek" to 1 (I think).
Thanks @caioketo for your answer. But it's not possible to not show the days Saturday and Sunday. The calendar was not built to omit some of the days. This calendar covers only the most common scenarios (i.e. it behaves like a normal week view calendars. e.g. google calendar). I don't think its possible to cover all special case scenarios.
Also can you provide an example app where its possible to zoom/pinch in the week view.
@alamkanak my bad, I thought as the variables, it should be able, but didnt test it out. And for the example, I didnt make it, as for my needs its not usefull, but, if u wants I can try that out.
Thank you to you both. Google Calendar as a pinch vertical zoom in week view. S planner has both axes zoom.
I succeeded in hiding Saturday and Sunday but it causes some day shifting on Monday.
Thank you in advance
Thanks @sylvaindd. I think it's a good idea to implement the vertical zoom. The horizontal one may cause some issues here. I'll surely look into it.
Yes I think the vertical zoom is enough. Thank you for your answers.
@alamkanak the vertical would be changing the "height" of the hours dont?
@caioketo yes that's it I guess, I think it just needs the multi touch implementation.
@alamkanak I see, right now im at work, so I can't really try it out, but if you want, I can make some tests after I get home.
@caioketo did you try it out ?
@sylvaindd I havent got time yet, since its not nescessary for what I'm using it, it will take a little long for me to try that.. sorry.
I created a method to handle the zoom which is :
mScaleDetector = new ScaleGestureDetector(mContext, new OnScaleGestureListener() {
public void onScaleEnd(ScaleGestureDetector detector) {
}
public boolean onScaleBegin(ScaleGestureDetector detector) {
return true;
}
public boolean onScale(ScaleGestureDetector detector) {
System.out.println(mHourHeight);
if (detector.getScaleFactor() > 1 && mHourHeight < 200) {
mHourHeight += 4 * detector.getScaleFactor();
// Zoom
// mHourHeight += 5;
}
else if (detector.getScaleFactor() < 1 && mHourHeight > 80) {
mHourHeight -= 4 * (detector.getScaleFactor() + 1);
// deZoom
// mHourHeight -= 5;
}
return false;
}
});
And called it in onTouchEvent():
mScaleDetector.onTouchEvent(event);
It's working but it doesn't center the calendar to the position I'm zooming. I'd like to know if there was a way to center the calendar with X and Y axes ?
Than you
Up ! I wanted to know if you started implementing this feature ? I will realease an application using your library soon and my zoom feature is working but not really smoothly.
Thank you in advance,
I've been working on implementing this. Just some slight problems left, but expect a PR soon.
HI, That would be very nice. I kinda upgraded my implementation but it's still not smooth. Anyway, if you could keep me informed about your implementation, that would be nice.
I got it working so it follows the current position in the view.
The two problems I currently still have is that
- [x] it sometimes still starts scrolling while zooming (especially annoying when it comes to horizontal scrolling)
- [x] there should be a dynamic minium hourHeight (that depends on the screenHeight, otherwise the view is sometimes smaller than the available height).
(You'll be able to set the min and max hourHeight manually too btw)
I actually managed to resolve this problem : "otherwise the view is sometimes smaller than the available height" If you used a ScaleGestureDetector did you return true in onScale and onScaleBegin ? I had a problem with the scroll and zoom not working correctly together by returning false.
I do return true, but I'm not sure what I should do in the onTouch handler. Right now I do
return mScaleDetector.onTouchEvent(event) && mGestureDetector.onTouchEvent(event);
instead of
return mGestureDetector.onTouchEvent(event);
I currently do this : mScaleDetector.onTouchEvent(event); return mGestureDetector.onTouchEvent(event); Which I guess is pretty much the same as what you're doing
I think your implementation is even better. (in case the first one ever returns false)