0
可能是簡短答案的長問題。更改Visiblity時的Android動畫
我有一系列我動畫使用AnimationDrawable類當按下按鈕圖像(在網格視圖中顯示)的。
動畫代碼片段;
AnimationDrawable mAnimation;
view.setImageDrawable(null);
Random randomGenerator = new Random();
int rand = randomGenerator.nextInt(6);
BitmapDrawable frame0 = (BitmapDrawable)context.getResources().getDrawable(spinImages.get(0));
BitmapDrawable frame1 = (BitmapDrawable)context.getResources().getDrawable(spinImages.get(1));
BitmapDrawable last = (BitmapDrawable)context.getResources().getDrawable(endImages.get(rand));
mAnimation = new AnimationDrawable();
mAnimation.isOneShot();
for (int i=0; i < spinNumber; i++) {
mAnimation.addFrame(frame0, spinDuration);
mAnimation.addFrame(frame1, spinDuration);
}
mAnimation.addFrame(last, spinDuration);
view.setBackgroundDrawable(mAnimation);
view.setTag(rand);
mAnimation.start();
也有微調,將篩選基於所選值的圖像,設置一些無形的(一切運作良好高達了這一點)。
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
int index = arg0.getSelectedItemPosition();
String[] filterOptions;
filterOptions = getResources().getStringArray(R.array.spn_options);
// hide all below filter value
GridView gridView = (GridView) findViewById(R.id.grid_view);
for (int i=0; i < ((ViewGroup)gridView).getChildCount(); ++i) {
View nextChild = ((ViewGroup)gridView).getChildAt(i);
nextChild.setVisibility(View.VISIBLE);
if (nextChild instanceof ImageView) {
// get tag
if (Integer.parseInt(nextChild.getTag().toString()) < arg2) {
nextChild.setVisibility(View.INVISIBLE);
}
nextChild.getTag();
}
}
}
問題是,當顯示所有的微調選擇我的圖像上應用setVisibility(View.VISIBLE)
;這會使圖像重新出現,但會再次觸發動畫。我希望圖像重新出現,僅顯示動畫的最終狀態。
任何想法?