I'm trying to create collapsable calendar.
I'm using custom calendarView in ViewPager, so when expand/collapse button pressed my calendarView animate collapsing all calendar weeks except only one.
Goal is to swipe month when expanded (which works as i want) and swipe weeks when collapsed.
Below calendarView is ListView with some events, when user collapse calendar - listView height must change.
Problem is when i trying to collapse calendarView in ViewPager, he doesn't change height.
calendarView is a LinearLayout with child views, when it is not in ViewPager, it animating and changing size.
I'm using little snippet to set ViewPager height to it children
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height = 0;
for(int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int h = child.getMeasuredHeight();
if(h > height) height = h;
}
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
I'm tried to override onMeasure on calendarView, used different animations, tried to change ViewPager layout directly but no luck.
Please help me with this problem, maybe there is a tip for it.
I found this, this, this, and a lot more questions
My question is very similar to this question
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…