Exemplo n.º 1
0
  @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    LogUtil.i("MoveLinearLayout", "[onMeasure] start");
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    int count = getChildCount();
    boolean sub2 = false, sub3 = false;
    View view;
    for (int i = 0; i < count; ++i) {
      view = getChildAt(i);

      if (view.getId() == R.id.sub_view_1) {
        LogUtil.i(
            "MoveLinearLayout", "[onMeasure] sub_view_1  widthMeasureSpec : " + widthMeasureSpec);
      }
      if (view.getId() == R.id.sub_view_2 && !sub2) {
        LogUtil.i(
            "MoveLinearLayout", "[onMeasure] sub_view_2  widthMeasureSpec : " + widthMeasureSpec);
        view.setLayoutParams(new LayoutParams(widthMeasureSpec, view.getLayoutParams().height));
        sub2 = true;
      }
      if (view.getId() == R.id.sub_view_3 && sub3 == false) {
        LogUtil.i(
            "MoveLinearLayout", "[onMeasure] : sub_view_3 widthMeasureSpec : " + widthMeasureSpec);
        view.setLayoutParams(new LayoutParams(widthMeasureSpec, view.getLayoutParams().height));
        sub3 = true;
      }
      if (sub2 && sub3) {
        break;
      }
    }
  }
Exemplo n.º 2
0
 @Override
 public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
   if (Math.abs(distanceY) > Math.abs(distanceX)) {
     return false;
   }
   mScrollX += distanceX;
   LogUtil.i("MoveLinearLayout", "[scrollDis] scrollTo  " + mScrollX);
   scrollDis();
   mIsScroll = true;
   return true;
 }