android 约束 布局_Android约束布局动画

本文介绍了如何在Android应用中实现约束布局动画,通过创建两个不同布局定义动画的起始和结束状态,利用ConstraintSet类动态设置约束。通过TransitionManager管理过渡效果,实现视图间的平滑动画。
摘要由CSDN通过智能技术生成

android 约束 布局

In this tutorial, we’ll be implementing Constraint Layout Animations in our Android Application.

在本教程中,我们将在Android应用程序中实现约束布局动画。

约束布局动画 (Constraint Layout Animation)

We can create beautiful animations using ConstraintLayout quickly. To do so, we need to just change constraints!

我们可以使用ConstraintLayout快速创建精美的动画。 为此,我们只需要更改约束即可!

The most common and easy way to create Constraint Layout animations in by creating two different layouts.
One is the start stage of the animation and the second is the end stage of the animation.

通过创建两个不同的布局来创建约束布局动画的最常见,最简单的方法。
第一个是动画的开始阶段,第二个是动画的结束阶段。

Constraint Set is the class used to set constraints on the views of the Constraint Layout.

约束集是用于在约束布局的视图上设置约束的类。

约束集 (ConstraintSet)

ConstraintSet is the class that is used to define constraints programmatically on the Constraint Layout.
It can also retrieve the constraints present in the Constraint Layout by using clone() method.

ConstraintSet是用于在Constraint Layout上以编程方式定义约束的类。
它还可以使用clone()方法检索约束布局中存在的约束。

clone() method is used to copy the constraints from the layout.

clone()方法用于从布局复制约束。

applyTo() is used to apply a constraint set onto the Constraint Layout.

applyTo()用于将约束集应用于“约束布局”。

A ConstraintSet is created just like any other Java object:

与其他任何Java对象一样,创建ConstraintSet:

ConstraintSet constraintSet = new ConstraintSet();

To set constraints on the views programmatically, we need to use connect().

要以编程方式在视图上设置约束,我们需要使用connect()

connect() establishes connections between sibling views or a view and the parent view.

connect()在兄弟视图或视图与父视图之间建立连接。

To create a ConstraintLayout animation we need:

要创建ConstraintLayout动画,我们需要:

TransitionManager – To manage the transitions.
beginDelayedTransition() – To start the transition from the first scene to second scene(first layout to the second layout).

TransitionManager –管理过渡。
beginDelayedTransition() –开始从第一个场景到第二个场景(从第一个布局到第二个布局)的过渡。

applyTo() – To apply the final constraints on the second layout.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值