Search in sources :

Example 21 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project Lazy by l123456789jy.

the class AnimationUtils method getLessenScaleAnimation.

/**
     * 获取一个缩小动画
     *
     * @param durationMillis   时间
     * @param animationListener  监听
     * @return 一个缩小动画
     */
public static ScaleAnimation getLessenScaleAnimation(long durationMillis, AnimationListener animationListener) {
    ScaleAnimation scaleAnimation = new ScaleAnimation(1.0f, 0.0f, 1.0f, 0.0f, ScaleAnimation.RELATIVE_TO_SELF, ScaleAnimation.RELATIVE_TO_SELF);
    scaleAnimation.setDuration(durationMillis);
    scaleAnimation.setAnimationListener(animationListener);
    return scaleAnimation;
}
Also used : ScaleAnimation(android.view.animation.ScaleAnimation)

Example 22 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project glitch-hq-android by tinyspeck.

the class Util method startScaleAnimation.

public static void startScaleAnimation(View v, int duration) {
    ScaleAnimation animation = new ScaleAnimation(1.0f, 1.0f, 0.0f, 1.0f);
    animation.setDuration(duration);
    v.startAnimation(animation);
}
Also used : ScaleAnimation(android.view.animation.ScaleAnimation)

Example 23 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project WordPress-Android by wordpress-mobile.

the class StatsUIHelper method showChildViews.

private static void showChildViews(ExpandableListAdapter mAdapter, LinearLayout mLinearLayout, int groupPosition, View groupView, boolean animate) {
    int childCount = Math.min(mAdapter.getChildrenCount(groupPosition), STATS_CHILD_MAX_ITEMS);
    if (childCount == 0) {
        return;
    }
    final ViewGroup childContainer = (ViewGroup) groupView.findViewById(R.id.layout_child_container);
    if (childContainer == null) {
        return;
    }
    int numExistingViews = childContainer.getChildCount();
    if (childCount < numExistingViews) {
        int numToRemove = numExistingViews - childCount;
        childContainer.removeViews(childCount, numToRemove);
        numExistingViews = childCount;
    }
    for (int i = 0; i < childCount; i++) {
        boolean isLastChild = (i == childCount - 1);
        if (i < numExistingViews) {
            View convertView = childContainer.getChildAt(i);
            mAdapter.getChildView(groupPosition, i, isLastChild, convertView, mLinearLayout);
        } else {
            View childView = mAdapter.getChildView(groupPosition, i, isLastChild, null, mLinearLayout);
            // remove the right/left padding so the child total aligns to left
            childView.setPadding(0, childView.getPaddingTop(), 0, // No padding bottom on last child
            isLastChild ? 0 : childView.getPaddingBottom());
            setViewBackgroundWithoutResettingPadding(childView, R.drawable.stats_list_item_child_background);
            childContainer.addView(childView);
        }
    }
    if (childContainer.getVisibility() != View.VISIBLE) {
        if (animate) {
            Animation expand = new ScaleAnimation(1.0f, 1.0f, 0.0f, 1.0f);
            expand.setDuration(ANIM_DURATION);
            expand.setInterpolator(getInterpolator());
            childContainer.startAnimation(expand);
        }
        childContainer.setVisibility(View.VISIBLE);
    }
    StatsUIHelper.setGroupChevron(true, groupView, groupPosition, animate);
}
Also used : ViewGroup(android.view.ViewGroup) ScaleAnimation(android.view.animation.ScaleAnimation) RotateAnimation(android.view.animation.RotateAnimation) Animation(android.view.animation.Animation) ImageView(android.widget.ImageView) View(android.view.View) Point(android.graphics.Point) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 24 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project simple-tool-tip by xizzhu.

the class ToolTipView method onPreDraw.

@Override
public boolean onPreDraw() {
    container.getViewTreeObserver().removeOnPreDrawListener(this);
    Context context = container.getContext();
    if (!(context instanceof Activity)) {
        return false;
    }
    DisplayMetrics displayMetrics = new DisplayMetrics();
    ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int displayWidth = displayMetrics.widthPixels;
    int displayHeight = displayMetrics.heightPixels;
    Rect rect = new Rect();
    anchorView.getWindowVisibleDisplayFrame(rect);
    int statusBarHeight = rect.top;
    int[] location = new int[2];
    anchorView.getLocationInWindow(location);
    int anchorTop = location[1] - statusBarHeight;
    int anchorLeft = location[0];
    int anchorWidth = anchorView.getWidth();
    int anchorHeight = anchorView.getHeight();
    int textWidth = text.getWidth();
    int textHeight = text.getHeight();
    int arrowWidth = arrow.getWidth();
    int arrowHeight = arrow.getHeight();
    if (gravity == Gravity.TOP || gravity == Gravity.BOTTOM) {
        int width = Math.max(textWidth, arrowWidth);
        int height = textHeight + arrowHeight;
        int leftPadding;
        int topPadding;
        if (gravity == Gravity.TOP) {
            topPadding = anchorTop - height;
        } else {
            // gravity == Gravity.BOTTOM
            topPadding = anchorTop + anchorHeight;
        }
        int anchorHorizontalCenter = anchorLeft + anchorWidth / 2;
        int left = anchorHorizontalCenter - width / 2;
        int right = left + width;
        leftPadding = Math.max(0, right > displayWidth ? displayWidth - width : left);
        container.setPadding(leftPadding, topPadding, 0, 0);
        ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) arrow.getLayoutParams();
        layoutParams.leftMargin = anchorHorizontalCenter - leftPadding - arrowWidth / 2;
        arrow.setLayoutParams(layoutParams);
        pivotX = anchorHorizontalCenter;
        pivotY = gravity == Gravity.TOP ? anchorTop : topPadding;
    } else {
        // gravity == Gravity.LEFT || gravity == Gravity.RIGHT
        int width = textWidth + arrowWidth;
        int height = Math.max(textHeight, arrowHeight);
        int leftPadding;
        int topPadding;
        int rightPadding;
        if (gravity == Gravity.LEFT) {
            leftPadding = Math.max(0, anchorLeft - width);
            rightPadding = displayWidth - anchorLeft;
            text.setMaxWidth(displayWidth - rightPadding - leftPadding - arrowWidth);
        } else {
            // gravity == Gravity.RIGHT
            leftPadding = anchorLeft + anchorWidth;
            rightPadding = 0;
        }
        int anchorVerticalCenter = anchorTop + anchorHeight / 2;
        int top = anchorVerticalCenter - height / 2;
        int bottom = top + height;
        topPadding = Math.max(0, bottom > displayHeight ? displayHeight - height : top);
        container.setPadding(leftPadding, topPadding, rightPadding, 0);
        ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) arrow.getLayoutParams();
        layoutParams.topMargin = anchorVerticalCenter - topPadding - arrowHeight / 2;
        arrow.setLayoutParams(layoutParams);
        pivotX = gravity == Gravity.LEFT ? anchorLeft : leftPadding;
        pivotY = anchorVerticalCenter;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
        container.setAlpha(0.0F);
        container.setPivotX(pivotX);
        container.setPivotY(pivotY);
        container.setScaleX(0.0F);
        container.setScaleY(0.0F);
        container.animate().setDuration(ANIMATION_DURATION).alpha(1.0F).scaleX(1.0F).scaleY(1.0F);
    } else {
        AnimationSet animationSet = new AnimationSet(true);
        animationSet.setDuration(ANIMATION_DURATION);
        animationSet.addAnimation(new AlphaAnimation(0.0F, 1.0F));
        animationSet.addAnimation(new ScaleAnimation(0.0F, 1.0F, 0.0F, 1.0F, pivotX, pivotY));
        container.startAnimation(animationSet);
    }
    return false;
}
Also used : Context(android.content.Context) Rect(android.graphics.Rect) ViewGroup(android.view.ViewGroup) Activity(android.app.Activity) DisplayMetrics(android.util.DisplayMetrics) AnimationSet(android.view.animation.AnimationSet) AlphaAnimation(android.view.animation.AlphaAnimation) ScaleAnimation(android.view.animation.ScaleAnimation)

Example 25 with ScaleAnimation

use of android.view.animation.ScaleAnimation in project android_frameworks_base by DirtyUnicorns.

the class BitmapsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final BitmapsView view = new BitmapsView(this);
    final FrameLayout layout = new FrameLayout(this);
    layout.addView(view, new FrameLayout.LayoutParams(480, 800, Gravity.CENTER));
    setContentView(layout);
    ScaleAnimation a = new ScaleAnimation(1.0f, 2.0f, 1.0f, 2.0f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f, ScaleAnimation.RELATIVE_TO_SELF, 0.5f);
    a.setDuration(2000);
    a.setRepeatCount(Animation.INFINITE);
    a.setRepeatMode(Animation.REVERSE);
    view.startAnimation(a);
}
Also used : FrameLayout(android.widget.FrameLayout) ScaleAnimation(android.view.animation.ScaleAnimation)

Aggregations

ScaleAnimation (android.view.animation.ScaleAnimation)114 AnimationSet (android.view.animation.AnimationSet)60 AlphaAnimation (android.view.animation.AlphaAnimation)56 Animation (android.view.animation.Animation)50 TranslateAnimation (android.view.animation.TranslateAnimation)40 ClipRectAnimation (android.view.animation.ClipRectAnimation)28 CurvedTranslateAnimation (com.android.server.wm.animation.CurvedTranslateAnimation)28 WindowAnimation_activityCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseEnterAnimation)26 WindowAnimation_activityCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityCloseExitAnimation)26 WindowAnimation_activityOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenEnterAnimation)26 WindowAnimation_activityOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_activityOpenExitAnimation)26 WindowAnimation_taskCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseEnterAnimation)26 WindowAnimation_taskCloseExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskCloseExitAnimation)26 WindowAnimation_taskOpenEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenEnterAnimation)26 WindowAnimation_taskOpenExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskOpenExitAnimation)26 WindowAnimation_taskToBackEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackEnterAnimation)26 WindowAnimation_taskToBackExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToBackExitAnimation)26 WindowAnimation_taskToFrontEnterAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontEnterAnimation)26 WindowAnimation_taskToFrontExitAnimation (com.android.internal.R.styleable.WindowAnimation_taskToFrontExitAnimation)26 WindowAnimation_wallpaperCloseEnterAnimation (com.android.internal.R.styleable.WindowAnimation_wallpaperCloseEnterAnimation)26