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;
}
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);
}
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);
}
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;
}
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);
}
Aggregations