Back to project page Billy.
The source code is released under:
GNU General Public License
If you think the Android project Billy listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.vibin.billy; /* ww w .j av a 2s . c o m*/ import android.content.Context; import android.os.Build; import android.util.AttributeSet; import android.widget.ScrollView; import com.android.volley.toolbox.NetworkImageView; /** * @author Cyril Mottier * A custom ScrollView which notifies when user scrolls. */ public class NotifyingScrollView extends ScrollView { private static final float DEFAULT_PARALLAX_FACTOR = 2.5F; NetworkImageView header; private OnScrollChangedListener mOnScrollChangedListener; public interface OnScrollChangedListener { void onScrollChanged(ScrollView who, int l, int t, int oldl, int oldt); } public NotifyingScrollView(Context context) { super(context); } public NotifyingScrollView(Context context, AttributeSet attrs) { super(context, attrs); } public NotifyingScrollView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Override protected void onFinishInflate() { super.onFinishInflate(); header = (NetworkImageView) findViewById(R.id.image_header); } @Override protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); float parallaxFactor = DEFAULT_PARALLAX_FACTOR; header.setTranslationY((float) t / parallaxFactor); if (mOnScrollChangedListener != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { mOnScrollChangedListener.onScrollChanged(this, l, t, oldl, oldt); } } public void setOnScrollChangedListener(OnScrollChangedListener listener) { mOnScrollChangedListener = listener; } }