2013-05-06 2 views
0

여러 버튼에 대해 애니메이션을 부드럽게 페이드 아웃 할 수 있습니까?Android : 여러 버튼에 대해 페이드 아웃 애니메이션 만들기 더 부드럽게

만든 fadeout.xml의 @ 입술/ANIM

<?xml version="1.0" encoding="UTF-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android"> 
<alpha 
    android:fromAlpha="1.0" 
    android:toAlpha="0.0" 
    android:interpolator="@android:anim/accelerate_interpolator" 
    android:duration="1500" 
    android:repeatCount="infinite" /> 
</set> 

애니메이션을

Animation fadeout = AnimationUtils.loadAnimation(this, R.anim.fadeout); 

을 설정하고

public void click (View v){ 
    button1.startAnimation(fadeout); 
    button2.startAnimation(fadeout); 
    button3.startAnimation(fadeout); 
    button4.startAnimation(fadeout); 
    button5.startAnimation(fadeout); 
    button6.startAnimation(fadeout); 
    button7.startAnimation(fadeout); 
    button8.startAnimation(fadeout); 
    button9.startAnimation(fadeout); 
    button10.startAnimation(fadeout); 
    button11.startAnimation(fadeout); 
    button12.startAnimation(fadeout); 
    button13.startAnimation(fadeout); 
    button14.startAnimation(fadeout); 
    button15.startAnimation(fadeout); 
} 

그것은 아니다 클릭 후 일부 버튼에 애니메이션을 적용하려면이 옵션을 사용하여 문제는 3-5 개의 버튼에 적용 할 때 문제가되지만, 위에있는 많은 버튼에 적용하면 뒤떨어집니다.

어쨌든이 애니메이션을 느리게하지 않고 많은 버튼에 적용 할 수 있습니까?

많은 애니메이션 버튼을 162 개의 버튼에 적용해야하기 때문에.

나는 테스트를 위해 Galaxy Nexus를 사용하고 있습니다.

+1

왜 ~ 160 개의 버튼에 개별적으로 적용해야합니까? 컨테이너보기에 왜 적용하지 않습니까? – Cornholio

+0

그래서 모든 버튼을 선택하고 컨테이너에 포장해야합니까? 그렇다면 어떤 종류의 용기? 그리드 레이아웃? LinearLayout? – user2341387

+1

그건 너에게 달렸어. - 그 많은 버튼으로, 내가 동적으로 추가한다고 가정하지? – Cornholio

답변

4

각 버튼에 애니메이션을 개별적으로 적용 할 필요는 없습니다. 대신 다른 레이아웃 (예 : GridLayout) 내부에 모두 고정하고 그 위에 애니메이션을 적용하십시오.