本文整理汇总了Java中android.view.View.startAnimation方法的典型用法代码示例。如果您正苦于以下问题:Java View.startAnimation方法的具体用法?Java View.startAnimation怎么用?Java View.startAnimation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.View
的用法示例。
在下文中一共展示了View.startAnimation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onFocusChange
import android.view.View; //导入方法依赖的package包/类
@Override
public void onFocusChange(View v, boolean hasFocus) {
int focus = 0;
if (hasFocus) {
focus = R.anim.enlarge;
} else {
focus = R.anim.decrease;
}
//如果有焦点就放大,没有焦点就缩小
Animation mAnimation = AnimationUtils.loadAnimation(
getActivity().getApplication(), focus);
mAnimation.setBackgroundColor(Color.TRANSPARENT);
mAnimation.setFillAfter(hasFocus);
v.startAnimation(mAnimation);
mAnimation.start();
v.bringToFront();
}
示例2: expand
import android.view.View; //导入方法依赖的package包/类
private static void expand(final View v) {
v.measure(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
final int targetHeight = v.getMeasuredHeight();
v.getLayoutParams().height = 0;
v.setVisibility(View.VISIBLE);
Animation a = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
v.getLayoutParams().height = interpolatedTime == 1
? LinearLayout.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);
}
示例3: collapse
import android.view.View; //导入方法依赖的package包/类
public void collapse(final View v) {
final int initialHeight = v.getMeasuredHeight();
Animation a = new Animation()
{
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
if(interpolatedTime == 1){
v.setVisibility(View.GONE);
}else{
v.getLayoutParams().height = initialHeight - (int)(initialHeight * interpolatedTime);
v.requestLayout();
}
}
@Override
public boolean willChangeBounds() {
return true;
}
};
// 1dp/ms
a.setDuration((int)(initialHeight / v.getContext().getResources().getDisplayMetrics().density));
v.startAnimation(a);
}
示例4: setSwipePosition
import android.view.View; //导入方法依赖的package包/类
/**
* Sets the horizontal position and translucency of the view being swiped.
*/
@SuppressLint("NewApi")
private void setSwipePosition(View view, float deltaX) {
float fraction = Math.abs(deltaX) / view.getWidth();
if (isRuntimePostGingerbread()) {
view.setTranslationX(deltaX);
view.setAlpha(1 - fraction);
} else {
// Hello, Gingerbread!
TranslateAnimation swipeAnim = new TranslateAnimation(deltaX, deltaX, 0, 0);
mCurrentX = deltaX;
mCurrentAlpha = (1 - fraction);
AlphaAnimation alphaAnim = new AlphaAnimation(mCurrentAlpha, mCurrentAlpha);
AnimationSet set = new AnimationSet(true);
set.addAnimation(swipeAnim);
set.addAnimation(alphaAnim);
set.setFillAfter(true);
set.setFillEnabled(true);
view.startAnimation(set);
}
}
示例5: animateHideView
import android.view.View; //导入方法依赖的package包/类
private void animateHideView(final int position) {
final View view = viewList.get(position);
FlipAnimation rotation = createFlipAnimation(0, -90, view.getWidth(), view.getHeight() / 2.0f);
rotation.setAnimationListener(new FlipAnimationsListenerBase(view) {
@Override
public void onAnimationEnd(Animation animation) {
super.onAnimationEnd(animation);
view.setVisibility(View.INVISIBLE);
if (position == viewList.size() - 1) {
animatorListener.setViewsClickable(true);
drawerLayout.closeDrawers();
}
}
});
view.startAnimation(rotation);
}
示例6: a
import android.view.View; //导入方法依赖的package包/类
private View a(Context context) {
View linearLayout = new LinearLayout(context);
LayoutParams layoutParams = new FrameLayout.LayoutParams(-2, a(context, (float) IntFloatWheelView.DEFAULT_VALUE));
layoutParams.gravity = 17;
linearLayout.setOrientation(0);
linearLayout.setLayoutParams(layoutParams);
Drawable gradientDrawable = new GradientDrawable();
gradientDrawable.setColor(-450944201);
gradientDrawable.setCornerRadius((float) a(context, 5.0f));
linearLayout.setBackgroundDrawable(gradientDrawable);
View imageView = new ImageView(context);
layoutParams = new LinearLayout.LayoutParams(a(context, 20.0f), a(context, 20.0f));
layoutParams.gravity = 16;
layoutParams.setMargins(a(this.a.f, 17.0f), a(this.a.f, 10.0f), a(this.a.f, 8.0f), a(this.a.f, 10.0f));
imageView.setLayoutParams(layoutParams);
imageView.setScaleType(ScaleType.FIT_CENTER);
imageView.setImageDrawable(a(context, a.d));
Animation rotateAnimation = new RotateAnimation(0.0f, 359.0f, 1, 0.5f, 1, 0.5f);
rotateAnimation.setRepeatCount(-1);
rotateAnimation.setDuration(900);
rotateAnimation.setInterpolator(new LinearInterpolator());
imageView.startAnimation(rotateAnimation);
View textView = new TextView(context);
textView.setText(TextUtils.isEmpty(this.a.g) ? a.a : this.a.g);
textView.setTextSize(16.0f);
textView.setTextColor(-1);
layoutParams = new LinearLayout.LayoutParams(-2, -2);
layoutParams.gravity = 16;
layoutParams.setMargins(0, 0, a(context, 17.0f), 0);
textView.setLayoutParams(layoutParams);
linearLayout.addView(imageView);
linearLayout.addView(textView);
return linearLayout;
}
示例7: doExitAnim
import android.view.View; //导入方法依赖的package包/类
public void doExitAnim(final View contentView, long animDuration) {
if (builder.gravity == Gravity.BOTTOM) {
ValueAnimator exitAnimator = ValueAnimator.ofFloat(0, contentView.getHeight());
exitAnimator.setDuration(animDuration);
exitAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
float value = (float) animation.getAnimatedValue();
contentView.setTranslationY(value);
}
});
exitAnimator.start();
} else {
ScaleAnimation scaleAnimation = new ScaleAnimation(1.0F, 0.0F, 1.0F, 0.0F,
Animation.RELATIVE_TO_PARENT, 0.5F, Animation.RELATIVE_TO_PARENT, 0.5F);
scaleAnimation.setDuration(animDuration);
scaleAnimation.setFillAfter(true);
contentView.startAnimation(scaleAnimation);
}
}
示例8: startAlphaRevealAnimation
import android.view.View; //导入方法依赖的package包/类
/**
* For the Activity Circle Icon and text
*/
public static AnimationSet startAlphaRevealAnimation(final View VIEW) {
final int ANIMATION_DURATION = 1000;
final Animation mShowViewAnimation = new AlphaAnimation(0f, 1f);
mShowViewAnimation.setDuration(ANIMATION_DURATION);
AnimationSet mAnimations = new AnimationSet(true);
mAnimations.setInterpolator(new AccelerateDecelerateInterpolator());
mAnimations.addAnimation(mShowViewAnimation);
mAnimations.setFillAfter(true);
if(VIEW != null)
VIEW.startAnimation(mAnimations);
return mAnimations;
}
示例9: collapse
import android.view.View; //导入方法依赖的package包/类
public static void collapse(final View v) {
final int initialHeight = v.getMeasuredHeight();
Animation a = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
if (interpolatedTime == 1) {
v.setVisibility(View.GONE);
} else {
v.getLayoutParams().height = initialHeight - (int) (initialHeight * interpolatedTime);
v.requestLayout();
}
}
@Override
public boolean willChangeBounds() {
return true;
}
};
// 1dp/ms
a.setDuration((int) (initialHeight / v.getContext().getResources().getDisplayMetrics().density));
v.startAnimation(a);
}
示例10: rotationAnim
import android.view.View; //导入方法依赖的package包/类
/**
* Rotate ImageView
*
* @param view
*/
public static void rotationAnim(@NonNull View view) {
RotateAnimation rotateAnimation1 = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
rotateAnimation1.setInterpolator(new LinearInterpolator());
rotateAnimation1.setDuration(300);
rotateAnimation1.setRepeatCount(0);
view.startAnimation(rotateAnimation1);
}
示例11: enableView
import android.view.View; //导入方法依赖的package包/类
public static void enableView(View v) {
if (Build.VERSION.SDK_INT >= 11) {
try {
v.setAlpha(1.0f);
return;
} catch (Exception e) {
}
} else {
enableAnim.setDuration(100);
enableAnim.setFillAfter(true);
v.startAnimation(enableAnim);
}
}
示例12: setAnimation
import android.view.View; //导入方法依赖的package包/类
private void setAnimation(View viewToAnimate, int position) {
// If the bound view wasn't previously displayed on screen, it's animated
if (position > mLastPosition) {
Animation animation = AnimationUtils.loadAnimation(mContext, android.R.anim.slide_in_left);
viewToAnimate.startAnimation(animation);
mLastPosition = position;
}
}
示例13: start
import android.view.View; //导入方法依赖的package包/类
private void start(Tuple match) {
this.mRunningAnimation = match.mAnimation;
View view = getTarget();
if (view != null) {
view.startAnimation(this.mRunningAnimation);
}
}
示例14: openFABAnimation
import android.view.View; //导入方法依赖的package包/类
public void openFABAnimation(final View view, final View hint) {
Animation slideUp = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_up);
// Listener changes visibility to GONE on finish
view.setVisibility(View.VISIBLE);
hint.setVisibility(View.VISIBLE);
hint.startAnimation(slideUp);
view.startAnimation(slideUp);
}
示例15: showLine
import android.view.View; //导入方法依赖的package包/类
public static void showLine(Context context, View top, View bottom) {
Animation topTranslateAnimation=new TranslateAnimation(0, 0, -DensityUtil.dip2px(context, 56f), 0);
topTranslateAnimation.setDuration(300);
topTranslateAnimation.setInterpolator(context, android.R.anim.linear_interpolator);
topTranslateAnimation.setFillAfter(true);
top.startAnimation(topTranslateAnimation);
Animation bottomTranslateAnimation=new TranslateAnimation(0, 0, DensityUtil.dip2px(context, 56f), 0);
bottomTranslateAnimation.setDuration(300);
bottomTranslateAnimation.setInterpolator(context, android.R.anim.linear_interpolator);
bottomTranslateAnimation.setFillAfter(true);
bottom.startAnimation(bottomTranslateAnimation);
top.setVisibility(View.VISIBLE);
bottom.setVisibility(View.VISIBLE);
}