多层子View (subView) 动画 遮盖问题

1. 如在一个不满全屏的LinearLayout(设置属性为wrap_content方向上的动画)中 有三个控件 假设为 button1 button2 button3 (均同一层次)

这时对任何button设置动画不起作用或只在LinearLayout中起作用。

解决方案:获取LinearLayout布局 View 然后调用 bringtoFront() 从而占满余下全屏。详细理由如:

http://46aae4d1e2371e4aa769798941cef698.devproxy.yunshipei.com/wunghao8/article/details/42126527

2 同样在scrollView的子控件设置动画 动画只在scollView范围内起作用。

解决方案类似使其占满余下全屏 xml属性为

android:fillViewport="true"

总的代码结构如下。

 ViewGroup viewGroup = (ViewGroup) tv1.getParent();
                //v.setVisibility(View.GONE);
                int dis = viewGroup.getHeight();
                pv.setVisibility(View.VISIBLE);
                pv.bringToFront();
                ObjectAnimator.ofFloat(tv1, "translationY", dis - tv1.getTop(), 0).setDuration(50).start();
                ObjectAnimator.ofFloat(tv2, "translationY", dis - tv2.getTop(), 0).setDuration(250).start();
                ObjectAnimator.ofFloat(tv3, "translationY", dis - tv3.getTop(), 0).setDuration(300).start();

这里使用3.0属性动画作位移动画。pv--》scrollView、 tv1为button
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值