private void initFromAttributes(Context context, AttributeSet attrs) {
        TypedArray a = context.obtainStyledAttributes(attrs,
                R.styleable.ScrollLayout);
        if (a.hasValue(R.styleable.ScrollLayout_maxOffset)) {
            int maxset = a.getDimensionPixelOffset(R.styleable.ScrollLayout_maxOffset, maxOffset);
            if (maxset != getScreenHeight()) {
                maxOffset = getScreenHeight() - maxset;
            }
        }
        if (a.hasValue(R.styleable.ScrollLayout_minOffset))
            minOffset = a.getDimensionPixelOffset(R.styleable.ScrollLayout_minOffset, minOffset);
        if (a.hasValue(R.styleable.ScrollLayout_exitOffset)) {
            int exitset = a.getDimensionPixelOffset(R.styleable.ScrollLayout_exitOffset, getScreenHeight());
            if (exitset != getScreenHeight()) {
                exitOffset = getScreenHeight() - exitset;
            }
        }
        if (a.hasValue(R.styleable.ScrollLayout_allowHorizontalScroll))
            isAllowHorizontalScroll = a.getBoolean(R.styleable.ScrollLayout_allowHorizontalScroll, true);
        if (a.hasValue(R.styleable.ScrollLayout_isSupportExit))
            isSupportExit = a.getBoolean(R.styleable.ScrollLayout_isSupportExit, true);
        if (a.hasValue(R.styleable.ScrollLayout_mode)) {
            int mode = a.getInteger(R.styleable.ScrollLayout_mode, 0);
            switch (mode) {
                case 0x0:
                    setToOpen();
                    break;
                case 0x1:
                    setToClosed();
                    break;
                case 0x2:
                    setToExit();
                    break;
                default:
                    setToClosed();
                    break;
            }
        }
        a.recycle();
    }
Layout that can scroll down to a max offset and can tell the scroll progress by
OnScrollProgressListener.
scrolllayout/src/main/java/com/yinglan/scrolllayout/ScrollLayout.java