高斋晓开卷,独共圣人语。这篇文章主要讲述Android View 从左边滑出动画 ,以及从左上,左下,右上,右下放大动画。相关的知识,希望能为你提供帮助。
1.从左边滑出动画。
ViewTreeObserver vtobanniang = ivBanniang.getViewTreeObserver();
vtobanniang.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
ivBanniang.getViewTreeObserver().removeOnGlobalLayoutListener(this);
int width = ivBanniang.getWidth();
float[] x = {-width, 0};
ObjectAnimator objectAnimatorX = ObjectAnimator.ofFloat(ivBanniang, "translationX", x);
objectAnimatorX.setDuration(500);
objectAnimatorX.start();
}
});
2.从左上,左下,右上,右下放大出场动画。
中心点更改为左下角:
mGenderSelectorLinearLayout.setPivotX(0);
mGenderSelectorLinearLayout.setPivotY(mGenderSelectorLinearLayout.getHeight());
中心点更改为左上角:
mGenderSelectorLinearLayout.setPivotX(0);
mGenderSelectorLinearLayout.setPivotY(0);
中心点更改为右上角:
mGenderSelectorLinearLayout.setPivotX(mGenderSelectorLinearLayout.getWidth()); mGenderSelectorLinearLayout.setPivotY(0);
中心点更改为右下角:
mGenderSelectorLinearLayout.setPivotX(mGenderSelectorLinearLayout.getWidth());
mGenderSelectorLinearLayout.setPivotY(mGenderSelectorLinearLayout.getHeight());
动画:
public void showGenderSelectorAnimation() { if (mGenderSelectorLinearLayout == null) {return; } mGenderSelectorLinearLayout.post(new Runnable() { @Override public void run() { mGenderSelectorLinearLayout.setPivotX(0); mGenderSelectorLinearLayout.setPivotY(mGenderSelectorLinearLayout.getHeight()); ObjectAnimator scaleX = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleX", 0.0f, 1.05f); ObjectAnimator scaleY = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleY", 0.0f, 1.05f); AnimatorSet set = new AnimatorSet(); set.play(scaleX).with(scaleY); set.setDuration(330); set.start(); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (mGenderSelectorLinearLayout == null) { return; } ObjectAnimator scaleX2 = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleX", 1.05f, 0.98f); ObjectAnimator scaleY2 = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleY", 1.05f, 0.98f); AnimatorSet set2 = new AnimatorSet(); set2.play(scaleX2).with(scaleY2); set2.setDuration(150); set2.start(); set2.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { super.onAnimationEnd(animation); if (mGenderSelectorLinearLayout == null) { return; } ObjectAnimator scaleX3 = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleX", 0.98f, 1.0f); ObjectAnimator scaleY3 = ObjectAnimator.ofFloat(mGenderSelectorLinearLayout, "scaleY", 0.98f, 1.0f); AnimatorSet set3 = new AnimatorSet(); set3.play(scaleX3).with(scaleY3); set3.setDuration(300); set3.start(); } }); } }); } }); }
【Android View 从左边滑出动画 ,以及从左上,左下,右上,右下放大动画。】
推荐阅读
- Android | Android Studio打包APK安装失败(应用是非正式版本,当前设备不支持安装)
- Power Apps 弹出界面popup dialog
- Spring Boot + Spring Security + JWT + MySQL + React Full Stack Polling App - Part 1
- uniapp调取摄像头扫码和生成二维码
- Fastlane AppStore 执行流程分析
- uniapp框架uView多平台快速开发的UI框架
- HBuilder打包Wap2App方法
- 解析 pid=`ps -ef | grep $APP_NAME | grep -v grep | awk '{print $2}' `
- uni-app项目开发方式及搭建