textview随seekbar一起移动

来源:互联网 发布:js 特效 同意网站协议 编辑:程序博客网 时间:2024/06/18 16:45

主要思路是自定义一个SeekBar,然后上面的跟随窗口是用popwindow来实现的

主要的跟随代码如下:

 

protected synchronized void onDraw(Canvas canvas) {

  // TODO Auto-generated method stub

  int thumb_x = this.getProgress() * (this.getWidth() - mThumbWidth)

    / this.getMax();

  int middle = this.getHeight() / 2+40;

  super.onDraw(canvas);

 

  if (mPopupWindow != null) { 

   try {

    this.getLocationOnScreen(mPosition);

    mPopupWindow.update(thumb_x+mPosition[0] - getViewWidth(mView) / 2+mThumbWidth/2,

      middle,getViewWidth(mView),getViewHeight(mView));

   

   } catch (Exception e) {

    // TODO: handle exception

   }

  }

 

 }

这段代码主要重写了seekbar的ondraw方法,来判断跟随窗口该显示在哪个地方