@Override public void onClick(View v) { int id = v.getId(); View tempView = null; switch (id) { case R.id.lin_1: tempView = mSliding.getChildAt(0); break; case R.id.lin_2: tempView = mSliding.getChildAt(1); break; case R.id.lin_3: tempView = mSliding.getChildAt(2); break; case R.id.lin_4: tempView = mSliding.getChildAt(3); break; } if (tempView == preView) { return; } else { currentView = tempView; } stretchanimation.startAnimation(currentView); // clickEvent(currentView); onOffClickable(false); }
@AfterViews void initView() { mListView.setAdapter(adapter); // DisplayMetrics metric = new DisplayMetrics(); // getWindowManager().getDefaultDisplay().getMetrics(metric); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); Log.e("BBBBBBBBBBBBBBBBBBBB", dm.heightPixels + " " + dm.widthPixels + " "); measureSize(dm.heightPixels); stretchanimation = new StretchAnimation(maxSize, minSize, StretchAnimation.TYPE.vertical, 500); // 你可以换不能给的插值器 stretchanimation.setInterpolator(new DecelerateInterpolator()); // 动画时间 stretchanimation.setDuration(800); // 回调 stretchanimation.setOnAnimationListener(this); int childCount = mSliding.getChildCount(); View child; LayoutParams params = null; int index = 0; int sizeValue = 0; for (int i = 0; i < childCount; i++) { child = mSliding.getChildAt(i); child.setOnClickListener(this); params = child.getLayoutParams(); if (i == index) { preView = child; sizeValue = maxSize; } else { sizeValue = minSize; } params.height = sizeValue; child.setLayoutParams(params); } }