安卓放蘑菇街分类界面中小箭头的移动。研究了很久,
public void slideview(final View view) {
// 点击view的top,startheight为点击view的高度int p1 = view.getTop() + (startheight - arrowheight) / 2;
// 箭头一开始所处位置的top,需在oncreate里赋值mTop=arrow.getTop();
int p2 = mTop;
int viewtop = view.getTop();
int left = arrow.getLeft();
// 获取箭头的宽高
int width = arrow.getWidth();
int height = arrow.getHeight();
//点击View的宽高
int viewWidth = rl_hotstar.getWidth();
int viewheight = rl_hotstar.getHeight();
int VIEWOFFSET = (startheight - arrowheight) / 2;
//先让箭头做 移动动画
TranslateAnimation animation = new TranslateAnimation(0, 0, p2, p1);
animation.setInterpolator(new LinearInterpolator());
animation.setDuration(500);
animation.setStartOffset(100);
animation.setFillAfter(true);
// 表示动画已经做完
arrow.clearAnimation();
// arrow移动后的值赋给mTop
arrow.startAnimation(animation);
//动画做完之后给arrow定位(定位必须与移动动画目标位置一样,否则会出现弹跳效果。)
arrow.layout(left, viewtop + VIEWOFFSET, left + width, viewtop + VIEWOFFSET+ height);
mTop = arrow.getTop();
}