android裁剪部分放大动画,【Android】图片放大被截了一部分之认识clipChildren属性的用法...

前言

这两天在开发过程中,用到了许多动画,其中就有缩放动画,图片在放大之后,超出了原本的区域范围,然后就导致图片的一部分被截掉了,感觉略显尴尬哈,这怎么能行呢,于是乎,一顿学习(百度)之下,发现了clipChildren属性,很强大的样子,一顿操作后,完美解决~~

用法

clipChildren属性需要设置在最外层的根布局中。

clipChildren是布尔值类型,true表示动画被限定在父布局的区域之内,false表示动画可以超过父布局的边界。

代码中的应用

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

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

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity"

android:clipChildren="false"

>

android:layout_width="24dp"

android:layout_height="24dp">

android:layout_width="48dp"

android:layout_height="48dp"

android:src="@mipmap/ic_launcher"

android:scaleType="centerCrop"

/>

android:layout_width="24dp"

android:layout_height="24dp"

android:background="@color/colorPrimary"

/>

效果图

cca529db627d

image.png

紫色区域是我们父布局的限定区域,但是在使用了clipChildren属性之后,我们的ImageView的大小就扩展到48dp了,是不是很神奇呀,快来试一试吧~~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值