【发布时间】:2019-02-06 21:56:38
【问题描述】:
我正在创建一个动画,它可以移动、更改布局中视图的内容和大小。我正在使用约束布局。我有两个 xml 文件,一个用于常规布局,一个用于需要转换到的布局。
我需要更改:多个视图的约束、文本、文本大小和可见性。
我尝试使用:
ConstraintLayout rootLayout = (ConstraintLayout) findViewById(R.id.main);
ConstraintSet newConstraint = new ConstraintSet();
newConstraint.load(this, R.layout.activity_selected);
TransitionManager.beginDelayedTransition(rootLayout);
newConstraint.applyTo(rootLayout);
但这不会更新文本大小,因为它不是 ConstraintLyout 类的一部分
我也尝试过使用
selectedScene = Scene.getSceneForLayout(sceneRoot, R.layout.activity_selected, this);
TransitionManager.go(selectedScene, set);
但这并不能产生漂亮的动画,并且需要额外的复杂性,例如创建 setEnterAction() 等
在更改视图的文本和文本大小时,是否有一种优雅的方式来动画约束布局更改
【问题讨论】:
标签: java android android-layout user-interface android-animation