用ObjectorAnimator實現(xiàn)的,但點擊實現(xiàn)子view的動畫效果消失后,再點擊主Button就不能顯示了
設(shè)置了點擊子view后的setAlpha和Visibility都不行,怎么點主button都不能在顯示子view了,請教是怎么回事:
case R.id.id_imgb://點擊子view,讓其放大消失,其它view縮小消失
setSelected(arg0.getId());
//讓被點擊的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是屬性動畫,執(zhí)行完后是什么樣,它以后就是什么樣了,所以當(dāng)你動畫執(zhí)行結(jié)束后,所有的子view透明度都為0,大小為3倍或者0倍,正確的做法是,打開時,將所有子view的樣式和位置都重置(放回原來的位置,透明度置為1,大小為1倍)。
這個控件不應(yīng)該用ObjectAnimator做,建議敲代碼之前考慮好用哪種方法實現(xiàn)最合理