當前位置: 首頁>>代碼示例>>Java>>正文


Java Animation.setDuration方法代碼示例

本文整理匯總了Java中android.view.animation.Animation.setDuration方法的典型用法代碼示例。如果您正苦於以下問題:Java Animation.setDuration方法的具體用法?Java Animation.setDuration怎麽用?Java Animation.setDuration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.animation.Animation的用法示例。


在下文中一共展示了Animation.setDuration方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreate

import android.view.animation.Animation; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_start);
    view = findViewById(android.R.id.content);
    Animation mLoadAnimation = AnimationUtils.loadAnimation(getApplicationContext(), android.R.anim.fade_in);
    mLoadAnimation.setDuration(2000);
    view.startAnimation(mLoadAnimation);
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {

            Intent intent = new Intent(StartActivity.this, MainActivity.class);
            startActivity(intent);
            overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
        }
    },4000);
}
 
開發者ID:ahmeturganci,項目名稱:yanohesaplama,代碼行數:19,代碼來源:StartActivity.java

示例2: animateHeader

import android.view.animation.Animation; //導入方法依賴的package包/類
/**
 * Animates the marginTop property of the header between two specified
 * values.
 * 
 * @param startTop
 *            Initial value for the marginTop property.
 * @param endTop
 *            End value for the marginTop property.
 */
private void animateHeader(final float startTop, float endTop) {
	Log.v(TAG, "animateHeader");
	cancelAnimation();
	final float deltaTop = endTop - startTop;
	animation = new Animation() {
		@Override
		protected void applyTransformation(float interpolatedTime,
				Transformation t) {
			headerTop = (int) (startTop + deltaTop * interpolatedTime);
			realHeaderLayoutParams.topMargin = headerTop;
			realHeader.setLayoutParams(realHeaderLayoutParams);
		}
	};
	long duration = (long) (deltaTop / (float) headerHeight * ANIMATION_DURATION);
	animation.setDuration(Math.abs(duration));
	realHeader.startAnimation(animation);
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:27,代碼來源:QuickReturnHeaderHelper.java

示例3: animateIn

import android.view.animation.Animation; //導入方法依賴的package包/類
private void animateIn(FloatingActionButton button) {
    button.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(button)
                  .scaleX(1.0F)
                  .scaleY(1.0F)
                  .alpha(1.0F)
                  .setInterpolator(INTERPOLATOR)
                  .withLayer()
                  .setListener(null)
                  .start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(button.getContext(),
                android.support.design.R.anim.design_fab_in);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        button.startAnimation(anim);
    }
}
 
開發者ID:weixianshishen,項目名稱:BeautifulGirls,代碼行數:20,代碼來源:ScrollAwareFABBehavior.java

示例4: shakeAnimation

import android.view.animation.Animation; //導入方法依賴的package包/類
/**
 * 晃動動畫
 *
 * @param counts 1秒鍾晃動多少下
 * @return
 */
public static Animation shakeAnimation(int counts) {
    Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
    translateAnimation.setInterpolator(new CycleInterpolator(counts));
    translateAnimation.setDuration(1000);
    return translateAnimation;
}
 
開發者ID:mangestudio,項目名稱:GCSApp,代碼行數:13,代碼來源:ClearEditText.java

示例5: createHintSwitchAnimation

import android.view.animation.Animation; //導入方法依賴的package包/類
private static Animation createHintSwitchAnimation(final boolean expanded) {
    Animation animation = new RotateAnimation(expanded ? 45 : 0, expanded ? 0 : 45, Animation.RELATIVE_TO_SELF,
            0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
    animation.setStartOffset(0);
    animation.setDuration(100);
    animation.setInterpolator(new DecelerateInterpolator());
    animation.setFillAfter(true);

    return animation;
}
 
開發者ID:leobert-lan,項目名稱:UiLib,代碼行數:11,代碼來源:ArcMenu.java

示例6: startScaleDownAnimation

import android.view.animation.Animation; //導入方法依賴的package包/類
private void startScaleDownAnimation(Animation.AnimationListener listener) {
    mScaleDownAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            setAnimationProgress(1 - interpolatedTime);
        }
    };
    mScaleDownAnimation.setDuration(SCALE_DOWN_DURATION);
    mScaleDownAnimation.setAnimationListener(listener);
    mRefreshView.clearAnimation();
    mRefreshView.startAnimation(mScaleDownAnimation);
}
 
開發者ID:Bvin,項目名稱:gesture-refresh-layout,代碼行數:13,代碼來源:GestureRefreshLayout.java

示例7: fadeOut

import android.view.animation.Animation; //導入方法依賴的package包/類
static void fadeOut(View view, int duration) {
    Animation anim = new AlphaAnimation(1.0f, 0.0f);
    anim.setInterpolator(new AccelerateDecelerateInterpolator());
    anim.setDuration(duration);

    view.setAnimation(anim);
    view.setVisibility(View.GONE);
}
 
開發者ID:sega4revenge,項目名稱:Sega,代碼行數:9,代碼來源:SearchAnimator.java

示例8: shakeAnimation

import android.view.animation.Animation; //導入方法依賴的package包/類
/**
 * 晃動動畫
 * @param counts 半秒鍾晃動多少下
 * @return
 */
public static Animation shakeAnimation(int counts) {
    Animation translateAnimation = new TranslateAnimation(0, 10, 0, 0);
    translateAnimation.setInterpolator(new CycleInterpolator(counts));
    translateAnimation.setDuration(500);
    return translateAnimation;
}
 
開發者ID:LanguidSheep,項目名稱:sealtalk-android-master,代碼行數:12,代碼來源:ClearWriteEditText.java

示例9: setActivityToolbarPosition

import android.view.animation.Animation; //導入方法依賴的package包/類
public static void setActivityToolbarPosition(int duration, Toolbar aMainToolbar, Toolbar aDecorativeToolbar, Activity aActivity, float fromToolbarPosition, float toToolbarPosition, float fromMainToolbarPosition, float toMainToolbarPosition) {
	duration = duration < 0 ? 0 : duration;

	float distanceToMoveY = toToolbarPosition - fromToolbarPosition;
	float DECORATIVE_TOOLBAR_HEIGHT = -1 * aActivity.getResources().getDimension(R.dimen.additional_toolbar_height);
	float toTranslationY = (distanceToMoveY < DECORATIVE_TOOLBAR_HEIGHT) ? DECORATIVE_TOOLBAR_HEIGHT : distanceToMoveY;

	// We want to make sure the toolbar is as close to the final position as possible without being visible.
	// This ensures that the animation is only running when the toolbar is visible to the user.
	if(aDecorativeToolbar.getY() < DECORATIVE_TOOLBAR_HEIGHT) {
		aDecorativeToolbar.setY(DECORATIVE_TOOLBAR_HEIGHT);
		toTranslationY = (DECORATIVE_TOOLBAR_HEIGHT - toToolbarPosition) * -1;
	}

	Animation moveToolbarAnimation = new TranslateAnimation(0, 0, 0, toTranslationY);
	moveToolbarAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
	moveToolbarAnimation.setDuration(duration);
	moveToolbarAnimation.setFillAfter(true);

	float toDeltaY = toMainToolbarPosition - fromMainToolbarPosition;
	Animation moveMainToolbarAnimation = new TranslateAnimation(0, 0, 0, toDeltaY);
	moveMainToolbarAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
	moveMainToolbarAnimation.setDuration(duration);
	moveMainToolbarAnimation.setFillAfter(true);

	aMainToolbar.setBackgroundColor(Service.getColorAttribute(R.attr.colorPrimary, R.color.primary, aActivity));
	aMainToolbar.startAnimation(moveMainToolbarAnimation);
	aDecorativeToolbar.startAnimation(moveToolbarAnimation);
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:30,代碼來源:AnimationService.java

示例10: setupAnimation

import android.view.animation.Animation; //導入方法依賴的package包/類
private void setupAnimation() {
    mAnimation = new Animation() {
        @Override
        public void applyTransformation(float interpolatedTime, Transformation t) {
            mRotate = (interpolatedTime);
            invalidate();
        }
    };
    mAnimation.setRepeatCount(Animation.INFINITE);
    mAnimation.setRepeatMode(Animation.RESTART);
    mAnimation.setInterpolator(LINEAR_INTERPOLATOR);
    mAnimation.setDuration(ANIMATION_DURATION);
}
 
開發者ID:scwang90,項目名稱:SmartRefreshLayout,代碼行數:14,代碼來源:PhoenixHeader.java

示例11: expand

import android.view.animation.Animation; //導入方法依賴的package包/類
public  void expand(final View v) {
    v.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    final int targetHeight = v.getMeasuredHeight();

    // Older versions of android (pre API 21) cancel animations for views with a height of 0.
    v.getLayoutParams().height = 1;
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation()
    {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1
                    ? LayoutParams.WRAP_CONTENT
                    : (int)(targetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int)(targetHeight / v.getContext().getResources().getDisplayMetrics().density));
    v.startAnimation(a);
}
 
開發者ID:appteam-nith,項目名稱:Nimbus,代碼行數:28,代碼來源:GalleryView.java

示例12: createHintSwitchAnimation

import android.view.animation.Animation; //導入方法依賴的package包/類
private static Animation createHintSwitchAnimation(final boolean expanded) {
	Animation animation = new RotateAnimation(expanded ? 45 : 0, expanded ? 0 : 45, Animation.RELATIVE_TO_SELF,
			0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
	animation.setStartOffset(0);
	animation.setDuration(100);
	animation.setInterpolator(new DecelerateInterpolator());
	animation.setFillAfter(true);

	return animation;
}
 
開發者ID:cheenid,項目名稱:FLFloatingButton,代碼行數:11,代碼來源:RayMenu.java

示例13: setDefaultConfig

import android.view.animation.Animation; //導入方法依賴的package包/類
public static void setDefaultConfig(Animation animation, boolean isFinish) {
    if (isFinish) {
        animation.setDuration(DEFAULT_FINISH_ANIM_TIME);
        animation.setInterpolator(new AccelerateInterpolator());
        animation.setFillAfter(true);
    } else {
        animation.setDuration(DEFAULT_ANIM_TIME);
        animation.setInterpolator(new DecelerateInterpolator());
        animation.setFillAfter(false);
    }
    animation.setFillBefore(true);
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:13,代碼來源:UIIViewImpl.java

示例14: onClick

import android.view.animation.Animation; //導入方法依賴的package包/類
@Override
public void onClick(View view) {

    //Extract values from children
    LinearLayout rowsView = (LinearLayout) rootView.findViewById(R.id.repeatable_items);

    ArrayList<String> row = new ArrayList<>();
    for (int i = 0; i < rowsView.getChildCount(); ++i) {
        EditText et = (EditText) rowsView.getChildAt(i).findViewById(R.id.input_row);
        row.add(et.getText().toString());
    }
    fq.addRow(row);
    TextView tvCount = (TextView) rootView.findViewById(R.id.question_items_count);

    tvCount.setText(fq.getRows().size() + " items");
    Toast.makeText(FormSolverActivity.this, "SAVED", Toast.LENGTH_SHORT).show();

    Animation animation = new ScaleAnimation(1,1.1f,1,1.1f);
    animation.setDuration(300);
    animation.setRepeatMode(Animation.REVERSE);
    animation.setRepeatCount(1);
    tvCount.startAnimation(animation);

    //Remove any child from view
    ((LinearLayout) rootView.findViewById(R.id.repeatable_items)).removeAllViews();
    ((Button) rootView.findViewById(R.id.question_add_response_instance)).setText(getString(R.string.action_new_row));
    rootView.findViewById(R.id.question_add_response_instance).setOnClickListener(new onRowAddedListener(rootView, fq));
    fab.show();
}
 
開發者ID:feup-infolab,項目名稱:labtablet,代碼行數:30,代碼來源:FormSolverActivity.java

示例15: expand

import android.view.animation.Animation; //導入方法依賴的package包/類
/**
 * развернуть элемент
 *
 * @param v - тот кого мы будем разворачивать
 */
public static void expand(final View v) {
    v.measure(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
    final int targetHeight = v.getMeasuredHeight();

    // Older versions of android (pre API 21) cancel animations for views with a height of 0.
    v.getLayoutParams().height = 1;
    v.setVisibility(View.VISIBLE);
    Animation a = new Animation() {
        @Override
        protected void applyTransformation(float interpolatedTime, Transformation t) {
            v.getLayoutParams().height = interpolatedTime == 1 ?
                    WindowManager.LayoutParams.WRAP_CONTENT :
                    (int) (targetHeight * interpolatedTime);
            v.requestLayout();
        }

        @Override
        public boolean willChangeBounds() {
            return true;
        }
    };

    // 1dp/ms
    a.setDuration((int) (targetHeight / v.getContext()
            .getResources()
            .getDisplayMetrics().density));
    v.startAnimation(a);
}
 
開發者ID:interactiveservices,項目名稱:utils-android,代碼行數:34,代碼來源:AnimUtils.java


注:本文中的android.view.animation.Animation.setDuration方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。