android - setDuration 在动画类中不起作用
问题描述
我正在尝试使用 Animation 类为 ConstraintLayout 的高度设置动画,而 setDuration 方法似乎不起作用。高度会立即更改为所需的高度值。我在开发人员选项中看到过有关禁用动画的帖子,但这不是问题,它设置为 1x。无论如何,代码如下:
public static void scaleUp() {
Animation animation = new Animation() {
@Override
protected void applyTransformation(float interpolatedTime, Transformation t) {
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) profileLayout.getLayoutParams();
// modify your layout params here
params.height = 10;
profileLayout.setLayoutParams(params);
}
};
animation.setDuration(300); // in ms
profileLayout.startAnimation(animation);
}
解决方案
推荐阅读
- javascript - 未捕获(承诺):错误:未找到 MyOpportunitiesFilterPage 的组件工厂。你把它添加到@NgModule.entryComponents 了吗?
- arrays - strcpy() 在结构内的字符串上 - 未定义?
- javascript - Angular:我必须通过 javascript 将浏览器选项卡静音。没有。所有组件中的音频对象,所以我需要通用脚本来暂停应用程序音频
- php - 在 PHP 中将上传的 .PPM 文件转换为 .PNG,而无需在 Linux 中安装 ImageMagic 或任何其他 PHP 模块
- python - 将参考链接变成真正的目标 url - Producthunt API, python
- react-native - 开发服务器返回响应错误码:500 URL:http://localhost:8081/index.bundle?platform=android&dev=true&minify=false
- node.js - 开玩笑模拟 ioredis
- spring-security - 如何在运行时在 OAuth2 的 SAML 之间切换(使用 Spring Security)?
- git - 然后我在本地删除了一个分支为什么这个分支仍然在github上工作
- excel - 关于 MSForms.DataObject 的运行时错误 462