本文整理匯總了Java中android.view.animation.LinearInterpolator類的典型用法代碼示例。如果您正苦於以下問題:Java LinearInterpolator類的具體用法?Java LinearInterpolator怎麽用?Java LinearInterpolator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
LinearInterpolator類屬於android.view.animation包,在下文中一共展示了LinearInterpolator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.view.animation.LinearInterpolator; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setTheme(R.style.AppTheme);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_share_element);
mImageView = (ImageView) findViewById(R.id.image_view);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mImageView.setTransitionName(MainActivity.TRANSITION_NAME_SHARE);
} else {
ShareElementInfo info = getIntent().getExtras().getParcelable(MainActivity.EXTRA_SHARE_ELEMENT_INFO);
mShareElement = new FKJShareElement(info, this, mImageView.getRootView());
mShareElement.convert(mImageView)
.setDuration(ANIMATOR_DURATION)
.setInterpolator(new LinearInterpolator())
.startEnterAnimator();
}
}
示例2: startAnim
import android.view.animation.LinearInterpolator; //導入依賴的package包/類
/**
* 開始旋轉
*
* @param start
* @param end
* @param time
*/
private void startAnim(int start, final int end, long time) {
isAround = true;
mCurrentMode = MODE_ROTATE;
mValueAnimator = ValueAnimator.ofInt(start, end);
mValueAnimator.setDuration(time);
mValueAnimator.setRepeatCount(getRepeatCount());
mValueAnimator.setRepeatMode(ValueAnimator.RESTART);
mValueAnimator.setInterpolator(new LinearInterpolator());
mValueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
if (currentValue != (int) (animation.getAnimatedValue())) {
onAnimatorUpdate(animation);
}
}
});
mValueAnimator.start();
}
示例3: loadAnimation
import android.view.animation.LinearInterpolator; //導入依賴的package包/類
public void loadAnimation(boolean enabled) {
if (!enabled) {
currentScale = 1;
invalidate();
} else {
ValueAnimator valueAnimator = ValueAnimator.ofFloat(0.3f, 1.0f);
valueAnimator.setInterpolator(new LinearInterpolator());
valueAnimator.setDuration(animDuration);
valueAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
currentScale = (float) animation.getAnimatedValue();
invalidate();
}
});
valueAnimator.start();
}
}
示例4: startIncertitudeAnimator
import android.view.animation.LinearInterpolator; //導入依賴的package包/類
private void startIncertitudeAnimator() {
if (mColorAnimator == null) {
mColorAnimator = ValueAnimator.ofObject(new ArgbEvaluator(), mProgressColor, SkinHelper.getTranColor(mProgressColor, 0x10));
mColorAnimator.setInterpolator(new LinearInterpolator());
mColorAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
drawColor = (int) animation.getAnimatedValue();//之後就可以得到動畫的顏色了.
postInvalidate();
}
});
mColorAnimator.setDuration(1000);
mColorAnimator.setRepeatCount(ValueAnimator.INFINITE);
mColorAnimator.setRepeatMode(ValueAnimator.REVERSE);
}
mColorAnimator.start();
}
示例5: init
import android.view.animation.LinearInterpolator; //導入依賴的package包/類
private void init(Context context) {
mFlipAnimation = new RotateAnimation(0, -180,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
mFlipAnimation.setInterpolator(new LinearInterpolator());
mFlipAnimation.setDuration(250);
mFlipAnimation.setFillAfter(true);
mReverseFlipAnimation = new RotateAnimation(-180, 0,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
mReverseFlipAnimation.setDuration(250);
mReverseFlipAnimation.setFillAfter(true);
mRefreshView = (LinearLayout) View.inflate(context, R.layout.pull_to_refresh_header, null);
mRefreshViewText = (TextView) mRefreshView.findViewById(R.id.pull_to_refresh_text);
mRefreshViewImage = (ImageView) mRefreshView.findViewById(R.id.pull_to_refresh_image);
mRefreshViewProgress = (ProgressBar) mRefreshView.findViewById(R.id.pull_to_refresh_progress);
mRefreshViewLastUpdated = (TextView) mRefreshView.findViewById(R.id.pull_to_refresh_updated_at);
mRefreshState = PULL_TO_REFRESH;
mRefreshViewImage.setMinimumHeight(50); //設置下拉最小的高度為50
setFadingEdgeLength(0);
setHeaderDividersEnabled(false);
//把refreshview加入到listview的頭部
addHeaderView(mRefreshView);
super.setOnScrollListener(this);
mRefreshView.setOnClickListener(this);
mRefreshView.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
mRefreshViewHeight = mRefreshView.getMeasuredHeight();
mRefreshOriginalTopPadding = -mRefreshViewHeight;
resetHeaderPadding();
}
示例6: LineFadeIndicator
import android.view.animation.LinearInterpolator; //導入依賴的package包/類
public LineFadeIndicator(DachshundTabLayout dachshundTabLayout) {
this.dachshundTabLayout = dachshundTabLayout;
valueAnimator = new ValueAnimator();
valueAnimator.setInterpolator(new LinearInterpolator());
valueAnimator.setDuration(DEFAULT_DURATION);
valueAnimator.addUpdateListener(this);
valueAnimator.setIntValues(0,255);
paint = new Paint();
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.FILL);
rectF = new RectF();
startXLeft = (int) dachshundTabLayout.getChildXLeft(dachshundTabLayout.getCurrentPosition());
startXRight = (int) dachshundTabLayout.getChildXRight(dachshundTabLayout.getCurrentPosition());
edgeRadius = -1;
}
示例7: toolbarAnimateHide
import android.view.animation.LinearInterpolator; //導入依賴的package包/類
private void toolbarAnimateHide() {
if (mIsActionBarVisible) {
mCommonToolbar.animate()
.translationY(-mCommonToolbar.getHeight())
.setInterpolator(new LinearInterpolator())
.setDuration(180)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
toolbarSetElevation(0);
hideStatusBar();
if (mTocListPopupWindow != null && mTocListPopupWindow.isShowing()) {
mTocListPopupWindow.dismiss();
}
}
});
mIsActionBarVisible = false;
}
}
示例8: AnimatingDrawable
import android.view.animation.LinearInterpolator; //導入依賴的package包/類
private AnimatingDrawable(Drawable[] frames, long duration) {
mFrames = frames;
mAnimator = ValueAnimator.ofInt(0, mFrames.length - 1);
mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
// Normalize the position in case the interporator isn't linear
int pos = Math.max(Math.min((int) animation.getAnimatedValue(), mFrames.length - 1), 0);
setFrame(mFrames[pos]);
}
});
mAnimator.setDuration(duration);
mAnimator.setInterpolator(new LinearInterpolator());
// Calculate the largest drawable, and use that as our intrinsic width/height
for (Drawable drawable : mFrames) {
mIntrinsicWidth = Math.max(mIntrinsicWidth, drawable.getIntrinsicWidth());
mIntrinsicHeight = Math.max(mIntrinsicHeight, drawable.getIntrinsicWidth());
}
setFrame(mFrames[0]);
}
示例9: onNestedScroll
import android.view.animation.LinearInterpolator; //導入依賴的package包/類
@Override
public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout,
@NonNull FloatingActionButton child,
@NonNull View target,
int dxConsumed,
int dyConsumed,
int dxUnconsumed,
int dyUnconsumed) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
//child -> Floating Action Button
if (dyConsumed > 0) {
Log.d("Scrolling", "Up");
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) child.getLayoutParams();
int fab_bottomMargin = layoutParams.bottomMargin;
child.animate().translationY(child.getHeight() + fab_bottomMargin).setInterpolator(new LinearInterpolator()).start();
} else if (dyConsumed < 0) {
Log.d("Scrolling", "down");
child.animate().translationY(0).setInterpolator(new LinearInterpolator()).start();
}
}
示例10: initAnimations
import android.view.animation.LinearInterpolator; //導入依賴的package包/類
private void initAnimations() {
searchAnimation = ValueAnimator.ofFloat(0f, 1f);
searchAnimation.setDuration(50000);
searchAnimation.setRepeatCount(ValueAnimator.INFINITE);
searchAnimation.setRepeatMode(ValueAnimator.RESTART);
searchAnimation.setInterpolator(new LinearInterpolator());
searchAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
float angle = (valueAnimator.getAnimatedFraction() * 360);
ViewHelper.setTranslationX(ivSearch, (float) Math.sin(angle) * radius);
ViewHelper.setTranslationY(ivSearch, (float) Math.cos(angle) * radius);
}
});
scanAnimation = new TranslateAnimation(TranslateAnimation.RELATIVE_TO_PARENT, 0f, TranslateAnimation.RELATIVE_TO_PARENT, 0f, TranslateAnimation.RELATIVE_TO_PARENT, 0f, TranslateAnimation.RELATIVE_TO_PARENT, 0.61f);
scanAnimation.setDuration(2000);
scanAnimation.setRepeatCount(TranslateAnimation.INFINITE);
scanAnimation.setRepeatMode(TranslateAnimation.RESTART);
}
示例11: MoveXBy
import android.view.animation.LinearInterpolator; //導入依賴的package包/類
public void MoveXBy(float distance,long duration,final boolean StopRotationAtCurrentAngle)
{
final FriskyTanslations friskyTanslations1 =this;
Runnable runnable=new Runnable() {
@Override
public void run() {
if(StopRotationAtCurrentAngle)
{
friskyTanslations1.StopCrazyRotationAtCurrentAngle();
}
else
{
friskyTanslations1.StopCrazyRotationAtAngle(0);
}
}
};
view.animate().translationXBy(distance).setInterpolator(new LinearInterpolator()).withEndAction(runnable).setDuration(duration).start();
}
示例12: rotate
import android.view.animation.LinearInterpolator; //導入依賴的package包/類
public static void rotate(View v){
//創建旋轉動畫 對象 fromDegrees:旋轉開始的角度 toDegrees:結束的角度
RotateAnimation rotateAnimation = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
//設置動畫的顯示時間
rotateAnimation.setDuration(1000);
//設置動畫重複播放幾次
rotateAnimation.setRepeatCount(RotateAnimation.INFINITE);
//設置動畫插值器
rotateAnimation.setInterpolator(new LinearInterpolator());
//設置動畫重複播放的方式,翻轉播放
rotateAnimation.setRepeatMode(Animation.RESTART);
//拿著imageview對象來運行動畫效果
v.setAnimation(rotateAnimation);
}
示例13: CustomOscillation
import android.view.animation.LinearInterpolator; //導入依賴的package包/類
public void CustomOscillation(int startAngle, final int MaxAngleOfRotation,final int TimeToReachStartAngle,final int TimePeriodOfOscillation)
{
runnable1 = new Runnable() {
@Override
public void run() {
imageView.animate().rotationBy((-1)*MaxAngleOfRotation).withEndAction(runnable2).setDuration(TimePeriodOfOscillation).setInterpolator(new LinearInterpolator()).start();
}
};
runnable2 = new Runnable() {
@Override
public void run() {
imageView.animate().rotationBy(MaxAngleOfRotation).withEndAction(runnable1).setDuration(TimePeriodOfOscillation).setInterpolator(new LinearInterpolator()).start();
}
};
imageView.animate().rotationBy(startAngle).withEndAction(runnable1).setDuration(TimeToReachStartAngle).setInterpolator(new LinearInterpolator()).start();
}
示例14: StopCrazyRotationAtCurrentAngle
import android.view.animation.LinearInterpolator; //導入依賴的package包/類
public void StopCrazyRotationAtCurrentAngle()
{
runnable1 = new Runnable() {
@Override
public void run() {
imageView.animate().rotationBy(0).withEndAction(runnable2).setDuration(0).setInterpolator(new LinearInterpolator()).start();
}
};
runnable2 = new Runnable() {
@Override
public void run() {
imageView.animate().rotationBy(0).withEndAction(runnable1).setDuration(0).setInterpolator(new LinearInterpolator()).start();
}
};
imageView.animate().rotationBy(0).withEndAction(runnable1).setDuration(0).setInterpolator(new LinearInterpolator()).start();
}
示例15: init
import android.view.animation.LinearInterpolator; //導入依賴的package包/類
private void init(){
mView = getView();
mText = (TextView)mView.findViewById(R.id.txt);
img = (ImageView)mView.findViewById(R.id.img);
Animation operatingAnim = AnimationUtils.loadAnimation(getContext(), R.anim.loading_anim);
LinearInterpolator lin = new LinearInterpolator();
operatingAnim.setInterpolator(lin);
img.setAnimation(operatingAnim);
img.startAnimation(operatingAnim);
}