android 卡片放大变详情页,ConstraintLayout动画实现布局卡片式滑动放大缩放

本文介绍了如何使用ConstraintLayout在Android中实现卡片式布局,通过手势滑动实现卡片的放大和缩小效果。详细展示了从布局文件到Java代码的实现过程,并提供了关键代码段。
摘要由CSDN通过智能技术生成

ConstraintLayout(约束布局)是Android Studio 2.2中主要的新增功能之一,Android studio升级到2.3版本之后,不管是新建Activity或fragment,xml默认布局由RelativeLayout更改为ConstraintLayout了。

按照以往惯例先上效果图:

717d2723da11

GIF.gif

上图效果所示 根据手势滑动View 改变View的位置实现方法多种,此处记录下使用ConstraintLayout布局动画实现的过程(此篇笔记仅仅只记录应用demo,不讲解动画实现的原理,如有错误之处还望指正 3Q_):

1.首先保证Android studio升级到2.3版本之后,然后新建项目,编写xml布局(引用android.support.constraint.ConstraintLayout控件):

xmlns:app="http://schemas.android.com/apk/res-auto"

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="@color/colorPrimary"

android:orientation="vertical"

tools:context="com.dawnling.app.MainActivity">

android:id="@+id/imgBack"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_marginLeft="8dp"

android:layout_marginTop="15dp"

android:layout_marginBottom="15dp"

app:srcCompat="@mipmap/ic_back" />

android:layout_width="match_parent"

android:layout_height="match_parent"

android:id="@+id/main">

android:id="@+id/rlTop"

android:layout_width="0dp"

android:layout_height="375dp"

android:background="@drawable/shape_bg_qrcode_transparent"

app:layout_constraintTop_toTopOf="parent"

android:layout_marginEnd="16dp"

app:layout_constraintLeft_toLeftOf="parent"

app:layout_constraintRight_toRightOf="parent"

android:layout_marginStart="16dp">

android:id="@&#

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值