android.widget.ScrollView.onMeasure()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(182)

本文整理了Java中android.widget.ScrollView.onMeasure()方法的一些代码示例,展示了ScrollView.onMeasure()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScrollView.onMeasure()方法的具体详情如下:
包路径:android.widget.ScrollView
类名称:ScrollView
方法名:onMeasure

ScrollView.onMeasure介绍

暂无

代码示例

代码示例来源:origin: bluejamesbond/TextJustify-Android

@SuppressWarnings("DrawAllocation")
@Override
protected void onMeasure(final int widthMeasureSpec, final int heightMeasureSpec) {
  final int width = MeasureSpec.getSize(widthMeasureSpec);
  switch (measureState) {
    case FINISH_AWAIT:
      break;
    case AWAIT:
      break;
    case FINISH:
      viewportView.setMinimumWidth(width);
      viewportView.setMinimumHeight(layout.getMeasuredHeight());
      measureState = MeasureTaskState.FINISH_AWAIT;
      if(cacheConfig != CacheConfig.NO_CACHE){
        allocateResources();
      }
      break;
    case START:
      if (measureTask != null) {
        measureTask.cancel(true);
        measureTask = null;
      }
      measureTask = new MeasureTask(width);
      measureTask.execute();
      measureState = MeasureTaskState.AWAIT;
      break;
  }
  super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

代码示例来源:origin: layerhq/Atlas-Android

@Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    heightMeasureSpec = MeasureSpec.makeMeasureSpec(mMaxHeight, MeasureSpec.AT_MOST);
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }
}

代码示例来源:origin: DoodleScheduling/android-material-chips

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  if(mMaxHeight != DEFAULT_MAX_HEIGHT) {
    heightMeasureSpec = MeasureSpec.makeMeasureSpec(mMaxHeight, MeasureSpec.AT_MOST);
  }
  super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

代码示例来源:origin: kngfrhzs/panter-dialog

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST);
  super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}

代码示例来源:origin: yaa110/Memento

@Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    heightMeasureSpec = MeasureSpec.makeMeasureSpec(App.DEVICE_HEIGHT / 2, MeasureSpec.AT_MOST);
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }
}

代码示例来源:origin: derry/delion

@Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int maxHeight = (int) (MAX_HEIGHT_DP * mDpToPx);
    heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST);
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }
}

代码示例来源:origin: derry/delion

@Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    final int maxDialogWidthInPx = (int) (MAX_TABLET_DIALOG_WIDTH_DP
        * mContext.getResources().getDisplayMetrics().density);
    if (MeasureSpec.getSize(widthMeasureSpec) > maxDialogWidthInPx) {
      widthMeasureSpec = MeasureSpec.makeMeasureSpec(maxDialogWidthInPx,
          MeasureSpec.EXACTLY);
    }
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }
};

代码示例来源:origin: derry/delion

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  if (mNewTabPageLayout != null) {
    mNewTabPageLayout.setParentViewportHeight(MeasureSpec.getSize(heightMeasureSpec));
  }
  super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

代码示例来源:origin: CrazyPumPkin/DragMoreScrollView

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  int height = MeasureSpec.getSize(heightMeasureSpec);
  //图片撑满父布局
  mPhotoView.getLayoutParams().height = height;
  ((MarginLayoutParams) mDetailContainer.getLayoutParams()).topMargin = mPhotoReservedHeight;
  //详情视图最开始位移隐藏起来
  int detailTranslationY = height - mPhotoReservedHeight;
  mDetailContainer.setTranslationY(detailTranslationY);
  mDetailView.setTranslationY(detailTranslationY);
  super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

代码示例来源:origin: derry/delion

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  // This assumes that view's layout_width and layout_height are set to match_parent.
  assert MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY;
  assert MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY;
  int width = MeasureSpec.getSize(widthMeasureSpec);
  int height = MeasureSpec.getSize(heightMeasureSpec);
  View head = findViewById(R.id.signin_confirmation_head);
  RelativeLayout.LayoutParams headLayoutParams =
      (RelativeLayout.LayoutParams) head.getLayoutParams();
  View accountImage = findViewById(R.id.signin_account_image);
  LinearLayout.LayoutParams accountImageLayoutParams =
      (LinearLayout.LayoutParams) accountImage.getLayoutParams();
  if (height > width) {
    // Sets aspect ratio of the head to 16:9.
    headLayoutParams.height = width * 9 / 16;
    accountImageLayoutParams.topMargin = 0;
  } else {
    headLayoutParams.height = LayoutParams.WRAP_CONTENT;
    // Adds top margin.
    accountImageLayoutParams.topMargin =
        getResources().getDimensionPixelOffset(R.dimen.signin_screen_top_padding);
  }
  head.setLayoutParams(headLayoutParams);
  accountImage.setLayoutParams(accountImageLayoutParams);
  super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

代码示例来源:origin: derry/delion

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  // This assumes that view's layout_width and layout_height are set to match_parent.
  assert MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY;
  assert MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY;
  int width = MeasureSpec.getSize(widthMeasureSpec);
  int height = MeasureSpec.getSize(heightMeasureSpec);
  View title = findViewById(R.id.signin_title);
  ViewGroup.LayoutParams params = title.getLayoutParams();
  if (height > width) {
    // Sets the title aspect ratio to be 16:9.
    params.height = width * 9 / 16;
    title.setPadding(
        title.getPaddingLeft(), 0, title.getPaddingRight(), title.getPaddingBottom());
  } else {
    params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
    // Adds top padding.
    title.setPadding(title.getPaddingLeft(),
        getResources().getDimensionPixelOffset(R.dimen.signin_screen_top_padding),
        title.getPaddingRight(), title.getPaddingBottom());
  }
  title.setLayoutParams(params);
  super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}

代码示例来源:origin: derry/delion

@Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    // This assumes that view's layout_width is set to match_parent.
    assert MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY;
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = MeasureSpec.getSize(heightMeasureSpec);

    final ButtonCompat mReloadButton = (ButtonCompat) findViewById(R.id.sad_tab_reload_button);

    final LinearLayout.LayoutParams mReloadButtonParams =
        (LinearLayout.LayoutParams) mReloadButton.getLayoutParams();

    if ((width > height || width > mThresholdPx) && mReloadButton.getWidth() <= width) {
      // Orientation is landscape
      mReloadButtonParams.width = LinearLayout.LayoutParams.WRAP_CONTENT;
      mReloadButtonParams.gravity = Gravity.END;
    } else {
      // Orientation is portrait
      mReloadButtonParams.width = LinearLayout.LayoutParams.MATCH_PARENT;
      mReloadButtonParams.gravity = Gravity.FILL_HORIZONTAL;
    }

    mReloadButton.setLayoutParams(mReloadButtonParams);
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }
}

相关文章

ScrollView类方法