Created
November 24, 2013 09:31
-
-
Save billynyh/7625186 to your computer and use it in GitHub Desktop.
ParallaxImageView copy from notboringactionbar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.flavienlaurent.notboringactionbar; | |
import android.content.Context; | |
import android.graphics.Canvas; | |
import android.util.AttributeSet; | |
import android.widget.ImageView; | |
/** | |
* Created by f.laurent on 21/11/13. | |
* antoine-merle.com inspiration | |
*/ | |
public class ParallaxImageView extends ImageView { | |
private int mCurrentTranslation; | |
public ParallaxImageView(Context context) { | |
super(context); | |
} | |
public ParallaxImageView(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
public ParallaxImageView(Context context, AttributeSet attrs, int defStyle) { | |
super(context, attrs, defStyle); | |
} | |
public void setCurrentTranslation(int currentTranslation) { | |
mCurrentTranslation = currentTranslation; | |
invalidate(); | |
} | |
@Override | |
public void draw(Canvas canvas) { | |
canvas.save(); | |
canvas.translate(0, -mCurrentTranslation / 2) ; | |
super.draw(canvas); | |
canvas.restore(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment