用ObjectorAnimator實(shí)現(xiàn)的,但點(diǎn)擊實(shí)現(xiàn)子view的動(dòng)畫效果消失后,再點(diǎn)擊主Button就不能顯示了
設(shè)置了點(diǎn)擊子view后的setAlpha和Visibility都不行,怎么點(diǎn)主button都不能在顯示子view了,請教是怎么回事:
case R.id.id_imgb://點(diǎn)擊子view,讓其放大消失,其它view縮小消失
setSelected(arg0.getId());
//讓被點(diǎn)擊的view放大消失,其它view縮小消失
private void setSelected(int viewId)
{
ObjectAnimator animator;
ObjectAnimator animator1;
for (int i = 1; i < childs.size(); i++)
{
if ((childs.get(i)).getId() == viewId)
{
animator = ObjectAnimator.ofFloat(childs.get(i), View.SCALE_X,
1.0f, 3.0f).setDuration(300);
animator1 = ObjectAnimator.ofFloat(childs.get(i), View.SCALE_Y,
1.0f, 3.0f).setDuration(300);
} else
{
animator = ObjectAnimator.ofFloat(childs.get(i), View.SCALE_X,
1.0f, 0).setDuration(300);
animator1 = ObjectAnimator.ofFloat(childs.get(i), View.SCALE_Y,
1.0f, 0).setDuration(300);
}
ObjectAnimator animator2 = ObjectAnimator.ofFloat(childs.get(i),
View.ALPHA, 1.0f, 0).setDuration(300);
AnimatorSet set = new AnimatorSet();
set.playTogether(animator, animator1, animator2);
set.start();
2016-04-21
ObjectAnimator是屬性動(dòng)畫,執(zhí)行完后是什么樣,它以后就是什么樣了,所以當(dāng)你動(dòng)畫執(zhí)行結(jié)束后,所有的子view透明度都為0,大小為3倍或者0倍,正確的做法是,打開時(shí),將所有子view的樣式和位置都重置(放回原來的位置,透明度置為1,大小為1倍)。
這個(gè)控件不應(yīng)該用ObjectAnimator做,建議敲代碼之前考慮好用哪種方法實(shí)現(xiàn)最合理