博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
motion filter_Android Motion布局
阅读量:2534 次
发布时间:2019-05-11

本文共 3532 字,大约阅读时间需要 11 分钟。

motion filter

In this tutorial, we’ll be discussing and implementing the MotionLayout in our android application.

在本教程中,我们将在Android应用程序中讨论和实现MotionLayout。

Android MotionLayout (Android MotionLayout)

Android MotionLayout is introduced with Constraint Layout 2.0. The idea is to create interactive fluid motion like UI layouts with ease.

Android MotionLayout是在Constraint Layout 2.0中引入的。 想法是轻松创建类似于UI布局的交互式流体运动。

Previously, we used to use the following things to animate components in our application.

以前,我们曾经使用以下内容为应用程序中的组件制作动画。

  • PropertyAnimation

    PropertyAnimation
  • Animated Vector Drawable

    动画矢量可绘制
  • CoordinatorLayout

    协调器布局
  • Layout Transitions

    布局过渡

Motion Layout aims to make it better and easier to animate layouts.

Motion Layout旨在使动画制作变得更好,更容易。

To use motion layouts, add the following dependency:

要使用动作布局,请添加以下依赖项:

implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'

A MotionLayout can be used in place of ConstraintLayout. This is because a MotionLayout has all the properties of a ConstraintLayout(and much more as well shall see!).

可以使用MotionLayout代替ConstraintLayout。 这是因为MotionLayout具有ConstraintLayout的所有属性(还会看到更多!)。

A MotionLayout comprises of three core things:

MotionLayout包含三项核心内容:

  • Starting layout

    开始布局
  • Ending layout that has the ending constraints

    具有结尾约束的结尾布局
  • Motion scene

    运动场景

Starting and ending layouts are basic xml layout.

起始和结束布局是基本的xml布局。

A motion scene is where we define the underlying motion.

We do so inside a <MotionScene/> tag.

运动场景是我们定义基础运动的地方。

我们在<MotionScene/>标记内执行此操作。

It can contain a Transition, ConstraintSet, KeyFrameSet, Touch Handling.

它可以包含Transition,ConstraintSet,KeyFrameSet,Touch Handling。

In this tutorial, we’ll focus on Transitions and Touch Handling.

在本教程中,我们将重点介绍过渡和触摸处理。

Let’s look at a sample android application in which we will implement a swipe function on a button on the basis of which the layout would swap its content. We call it SwipeToSwap Application

让我们看一个示例android应用程序,在该应用程序中我们将在按钮上实现滑动功能,在此基础上布局将交换其内容。 我们称它为SwipeToSwap应用程序

项目结构 (Project Structure)

Android Motion Layout Project Structure

Android Motion Layout Project Structure

Android Motion Layout项目结构

The motion scene is defined in the res | xml folder

运动场景在res | xml文件夹

(Code)

The code for the activity_main_start.xml layout is given below:

下面给出了activity_main_start.xml布局的代码:

app:layoutDescription is where we set the motion scene on the MotionLayout.
app:layoutDescription是我们在MotionLayout上设置运动场景的地方。

The code for the activity_main_end.xml layout is given below. It represents the end state after the transition.

下面给出了activity_main_end.xml布局的代码。 它表示过渡后的结束状态。

The code for the motion_scene.xml file is given below:

下面给出了motion_scene.xml文件的代码:

OnSwipe is a type of gesture performed on the UI component.

The UIComponent is specified in the touchAnchorId along with the swipe direction.

OnSwipe是在UI组件上执行的一种手势。

UIComponent与滑动方向一起在touchAnchorId指定。

Note: Other interactive gestures such as click can also be set in the following way:

注意:还可以通过以下方式设置其他交互手势,例如单击。

The output when the above application is run on an emulator is given below:

上面的应用程序在模拟器上运行时的输出如下:

Android Motion Layout Output

Android Motion Layout Output

Android Motion布局输出

That sums up this introductory tutorial on MotionLayout.

总结了有关MotionLayout的入门教程。

You can download the AndroidMotionLayout project from the link below or view the full source code in our Github Repository.

您可以从下面的链接下载AndroidMotionLayout项目,或在我们的Github存储库中查看完整的源代码。

翻译自:

motion filter

转载地址:http://fmlzd.baihongyu.com/

你可能感兴趣的文章
openssl 升级
查看>>
ASP.NET MVC:通过 FileResult 向 浏览器 发送文件
查看>>
CVE-2010-2883Adobe Reader和Acrobat CoolType.dll栈缓冲区溢出漏洞分析
查看>>
使用正确的姿势跨域
查看>>
AccountManager教程
查看>>
Android学习笔记(十一)——从意图返回结果
查看>>
算法导论笔记(四)算法分析常用符号
查看>>
ultraedit激活
查看>>
总结(6)--- python基础知识点小结(细全)
查看>>
亿级曝光品牌视频的幕后设定
查看>>
ARPA
查看>>
JSP开发模式
查看>>
我的Android进阶之旅------&gt;Android嵌入图像InsetDrawable的使用方法
查看>>
Detours信息泄漏漏洞
查看>>
win32使用拖放文件
查看>>
Android 动态显示和隐藏软键盘
查看>>
raid5什么意思?怎样做raid5?raid5 几块硬盘?
查看>>
【转】how can i build fast
查看>>
null?对象?异常?到底应该如何返回错误信息
查看>>
django登录验证码操作
查看>>