Slides by Bernhard Pflug, Senior Android developer @ Iconmobile during the Ulracode Munich Meetup #7
http://www.meetup.com/Ultracode-Munich/events/219689131/
14. public class VerticalViewPager extends ViewGroup {
. . .
!
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = getDefaultSize(0, widthMeasureSpec);
int height = getDefaultSize(0, heightMeasureSpec);
setMeasuredDimension(width, height);
int hPadding = getPaddingLeft()+getPaddingRight();
int vPadding = getPaddingTop()+getPaddingBottom();
int contentWidth = getChildMeasureSpec(widthMeasureSpec, hPadding , width);
int contentHeight = getChildMeasureSpec(heightMeasureSpec,vPadding , height);
groundView.measure(contentWidth, contentHeight);
int skyViewHeight = skyView.getLayoutParams().height;
int skyHeight = getChildMeasureSpec(heightMeasureSpec, vPadding, skyViewHeight);
skyView.measure(contentWidth, skyHeight);
}
!
. . .
!
}
Implementing custom swipe components
{} @ github.com/bernhardpflug/AndroidUtilities
Ground View
Sky View
15. @Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int width = r - l;
final int height = b - t;
int skyViewHeight = skyView.getMeasuredHeight();
skyView.layout(0, 0, width, skyView.getMeasuredHeight());
groundView.layout(0, skyViewHeight, width, height + skyViewHeight);
}
Implementing custom swipe components
{} @ github.com/bernhardpflug/AndroidUtilities
Ground View
Sky View
18. @Override
public void computeScroll() {
if (scroller.computeScrollOffset()) {
int x = scroller.getCurrX();
int y = scroller.getCurrY();
scrollTo(x, y);
postInvalidate();
}
}
Implementing custom swipe components
{} @ github.com/bernhardpflug/AndroidUtilities