android.widget.ImageView.requestLayout()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(13.2k)|赞(0)|评价(0)|浏览(145)

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

ImageView.requestLayout介绍

暂无

代码示例

代码示例来源:origin: jdsjlzx/LRecyclerView

private void setHeaderViewHeight(int height) {
 if (height < mHeaderViewHeight) height = mHeaderViewHeight;
 mHeaderView.getLayoutParams().height = height;
 mHeaderView.requestLayout();
}

代码示例来源:origin: aurelhubert/ahbottomnavigation

@Override
  public void onAnimationUpdate(ValueAnimator animator) {
    imageView.setImageDrawable(AHHelper.getTintDrawable(drawable,
        (Integer) animator.getAnimatedValue(), forceTint));
    imageView.requestLayout();
  }
});

代码示例来源:origin: mancj/MaterialSearchBar

/**
 * Set navigation drawer menu icon enabled
 *
 * @param navButtonEnabled icon enabled
 */
public void setNavButtonEnabled(boolean navButtonEnabled) {
  this.navButtonEnabled = navButtonEnabled;
  if (navButtonEnabled) {
    navIcon.setVisibility(VISIBLE);
    navIcon.setClickable(true);
    navIcon.getLayoutParams().width = (int) (50 * destiny);
    ((LayoutParams) inputContainer.getLayoutParams()).leftMargin = (int) (50 * destiny);
    arrowIcon.setVisibility(GONE);
  } else {
    navIcon.getLayoutParams().width = 1;
    navIcon.setVisibility(INVISIBLE);
    navIcon.setClickable(false);
    ((LayoutParams) inputContainer.getLayoutParams()).leftMargin = (int) (0 * destiny);
    arrowIcon.setVisibility(VISIBLE);
  }
  navIcon.requestLayout();
  placeHolder.requestLayout();
  arrowIcon.requestLayout();
}

代码示例来源:origin: GitLqr/LQRWeChat

ivLogo.setVisibility(View.VISIBLE);
tvName.setVisibility(View.VISIBLE);
ivLogo.requestLayout();
tvName.requestLayout();
llCells[i].setBackgroundResource(cellBack);

代码示例来源:origin: tommybuonomo/dotsindicator

@Override public void setValue(Object object, float value) {
  ViewGroup.LayoutParams params = dotIndicatorView.getLayoutParams();
  params.width = (int) value;
  dotIndicatorView.requestLayout();
 }
};

代码示例来源:origin: chat-sdk/chat-sdk-android

public void setIconSize(int width, int height) {
  messageIconView.getLayoutParams().width = width;
  messageIconView.getLayoutParams().height = height;
  messageIconView.requestLayout();
}

代码示例来源:origin: vlonjatg/progress-activity

private void inflateEmptyView() {
  if (emptyState == null) {
    view = inflater.inflate(R.layout.view_empty, null);
    emptyState = view.findViewById(R.id.layout_empty);
    emptyState.setTag(EMPTY);
    emptyStateImageView = view.findViewById(R.id.image_icon);
    emptyStateTitleTextView = view.findViewById(R.id.text_title);
    emptyStateContentTextView = view.findViewById(R.id.text_description);
    emptyStateImageView.getLayoutParams().width = emptyStateImageWidth;
    emptyStateImageView.getLayoutParams().height = emptyStateImageHeight;
    emptyStateImageView.requestLayout();
    emptyStateTitleTextView.setTextSize(emptyStateTitleTextSize);
    emptyStateTitleTextView.setTextColor(emptyStateTitleTextColor);
    emptyStateContentTextView.setTextSize(emptyStateContentTextSize);
    emptyStateContentTextView.setTextColor(emptyStateContentTextColor);
    if (emptyStateBackgroundColor != Color.TRANSPARENT) {
      this.setBackgroundColor(emptyStateBackgroundColor);
    }
    LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.addRule(CENTER_IN_PARENT);
    addView(emptyState, layoutParams);
  } else {
    emptyState.setVisibility(VISIBLE);
  }
}

代码示例来源:origin: vlonjatg/progress-activity

private void inflateEmptyView() {
  if (emptyState == null) {
    view = inflater.inflate(R.layout.view_empty, null);
    emptyState = view.findViewById(R.id.layout_empty);
    emptyState.setTag(EMPTY);
    emptyStateImageView = view.findViewById(R.id.image_icon);
    emptyStateTitleTextView = view.findViewById(R.id.text_title);
    emptyStateContentTextView = view.findViewById(R.id.text_description);
    emptyStateImageView.getLayoutParams().width = emptyStateImageWidth;
    emptyStateImageView.getLayoutParams().height = emptyStateImageHeight;
    emptyStateImageView.requestLayout();
    emptyStateTitleTextView.setTextSize(emptyStateTitleTextSize);
    emptyStateTitleTextView.setTextColor(emptyStateTitleTextColor);
    emptyStateContentTextView.setTextSize(emptyStateContentTextSize);
    emptyStateContentTextView.setTextColor(emptyStateContentTextColor);
    if (emptyStateBackgroundColor != Color.TRANSPARENT) {
      this.setBackgroundColor(emptyStateBackgroundColor);
    }
    LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.gravity = Gravity.CENTER;
    addView(emptyState, layoutParams);
  } else {
    emptyState.setVisibility(VISIBLE);
  }
}

代码示例来源:origin: vlonjatg/progress-activity

private void inflateEmptyView() {
  if (emptyState == null) {
    view = inflater.inflate(R.layout.view_empty, null);
    emptyState = view.findViewById(R.id.layout_empty);
    emptyState.setTag(EMPTY);
    emptyStateImageView = view.findViewById(R.id.image_icon);
    emptyStateTitleTextView = view.findViewById(R.id.text_title);
    emptyStateContentTextView = view.findViewById(R.id.text_description);
    emptyStateImageView.getLayoutParams().width = emptyStateImageWidth;
    emptyStateImageView.getLayoutParams().height = emptyStateImageHeight;
    emptyStateImageView.requestLayout();
    emptyStateTitleTextView.setTextSize(emptyStateTitleTextSize);
    emptyStateTitleTextView.setTextColor(emptyStateTitleTextColor);
    emptyStateContentTextView.setTextSize(emptyStateContentTextSize);
    emptyStateContentTextView.setTextColor(emptyStateContentTextColor);
    if (emptyStateBackgroundColor != Color.TRANSPARENT) {
      this.setBackgroundColor(emptyStateBackgroundColor);
    }
    LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.gravity = Gravity.CENTER;
    addView(emptyState, layoutParams);
  } else {
    emptyState.setVisibility(VISIBLE);
  }
}

代码示例来源:origin: tianshaojie/AndroidFine

@Override
protected void onLoadingDrawableSet(Drawable imageDrawable) {
  if (null != imageDrawable) {
    final int dHeight = imageDrawable.getIntrinsicHeight();
    final int dWidth = imageDrawable.getIntrinsicWidth();
    /**
     * We need to set the width/height of the ImageView so that it is
     * square with each side the size of the largest drawable dimension.
     * This is so that it doesn't clip when rotated.
     */
    ViewGroup.LayoutParams lp = mHeaderImage.getLayoutParams();
    lp.width = lp.height = Math.max(dHeight, dWidth);
    mHeaderImage.requestLayout();
    /**
     * We now rotate the Drawable so that is at the correct rotation,
     * and is centered.
     */
    mHeaderImage.setScaleType(ScaleType.MATRIX);
    Matrix matrix = new Matrix();
    matrix.postTranslate((lp.width - dWidth) / 2f, (lp.height - dHeight) / 2f);
    matrix.postRotate(getDrawableRotationAngle(), lp.width / 2f, lp.height / 2f);
    mHeaderImage.setImageMatrix(matrix);
  }
}

代码示例来源:origin: vlonjatg/progress-activity

private void inflateEmptyView() {
  if (emptyState == null) {
    view = inflater.inflate(R.layout.view_empty, null);
    emptyState = view.findViewById(R.id.layout_empty);
    emptyState.setTag(EMPTY);
    emptyStateImageView = view.findViewById(R.id.image_icon);
    emptyStateTitleTextView = view.findViewById(R.id.text_title);
    emptyStateContentTextView = view.findViewById(R.id.text_description);
    emptyStateImageView.getLayoutParams().width = emptyStateImageWidth;
    emptyStateImageView.getLayoutParams().height = emptyStateImageHeight;
    emptyStateImageView.requestLayout();
    emptyStateTitleTextView.setTextSize(emptyStateTitleTextSize);
    emptyStateTitleTextView.setTextColor(emptyStateTitleTextColor);
    emptyStateContentTextView.setTextSize(emptyStateContentTextSize);
    emptyStateContentTextView.setTextColor(emptyStateContentTextColor);
    if (emptyStateBackgroundColor != Color.TRANSPARENT) {
      this.setBackgroundColor(emptyStateBackgroundColor);
    }
    LayoutParams layoutParams = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.topToTop = ConstraintSet.PARENT_ID;
    layoutParams.bottomToBottom = ConstraintSet.PARENT_ID;
    layoutParams.startToStart = ConstraintSet.PARENT_ID;
    layoutParams.endToEnd = ConstraintSet.PARENT_ID;
    addView(emptyState, layoutParams);
  } else {
    emptyState.setVisibility(VISIBLE);
  }
}

代码示例来源:origin: vlonjatg/progress-activity

private void inflateErrorView() {
  if (errorState == null) {
    view = inflater.inflate(R.layout.view_error, null);
    errorState = view.findViewById(R.id.layout_error);
    errorState.setTag(ERROR);
    errorStateImageView = view.findViewById(R.id.image_icon);
    errorStateTitleTextView = view.findViewById(R.id.text_title);
    errorStateContentTextView = view.findViewById(R.id.text_description);
    errorStateButton = view.findViewById(R.id.button_retry);
    errorStateImageView.getLayoutParams().width = errorStateImageWidth;
    errorStateImageView.getLayoutParams().height = errorStateImageHeight;
    errorStateImageView.requestLayout();
    errorStateTitleTextView.setTextSize(errorStateTitleTextSize);
    errorStateTitleTextView.setTextColor(errorStateTitleTextColor);
    errorStateContentTextView.setTextSize(errorStateContentTextSize);
    errorStateContentTextView.setTextColor(errorStateContentTextColor);
    errorStateButton.setTextColor(errorStateButtonTextColor);
    errorStateButton.getBackground().setColorFilter(new LightingColorFilter(1, errorStateButtonBackgroundColor));
    if (errorStateBackgroundColor != Color.TRANSPARENT) {
      this.setBackgroundColor(errorStateBackgroundColor);
    }
    LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.addRule(CENTER_IN_PARENT);
    addView(errorState, layoutParams);
  } else {
    errorState.setVisibility(VISIBLE);
  }
}

代码示例来源:origin: vlonjatg/progress-activity

private void inflateErrorView() {
  if (errorState == null) {
    view = inflater.inflate(R.layout.view_error, null);
    errorState = view.findViewById(R.id.layout_error);
    errorState.setTag(ERROR);
    errorStateImageView = view.findViewById(R.id.image_icon);
    errorStateTitleTextView = view.findViewById(R.id.text_title);
    errorStateContentTextView = view.findViewById(R.id.text_description);
    errorStateButton = view.findViewById(R.id.button_retry);
    errorStateImageView.getLayoutParams().width = errorStateImageWidth;
    errorStateImageView.getLayoutParams().height = errorStateImageHeight;
    errorStateImageView.requestLayout();
    errorStateTitleTextView.setTextSize(errorStateTitleTextSize);
    errorStateTitleTextView.setTextColor(errorStateTitleTextColor);
    errorStateContentTextView.setTextSize(errorStateContentTextSize);
    errorStateContentTextView.setTextColor(errorStateContentTextColor);
    errorStateButton.setTextColor(errorStateButtonTextColor);
    errorStateButton.getBackground().setColorFilter(new LightingColorFilter(1, errorStateButtonBackgroundColor));
    if (errorStateBackgroundColor != Color.TRANSPARENT) {
      this.setBackgroundColor(errorStateBackgroundColor);
    }
    LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.gravity = Gravity.CENTER;
    addView(errorState, layoutParams);
  } else {
    errorState.setVisibility(VISIBLE);
  }
}

代码示例来源:origin: vlonjatg/progress-activity

private void inflateErrorView() {
  if (errorState == null) {
    view = inflater.inflate(R.layout.view_error, null);
    errorState = view.findViewById(R.id.layout_error);
    errorState.setTag(ERROR);
    errorStateImageView = view.findViewById(R.id.image_icon);
    errorStateTitleTextView = view.findViewById(R.id.text_title);
    errorStateContentTextView = view.findViewById(R.id.text_description);
    errorStateButton = view.findViewById(R.id.button_retry);
    errorStateImageView.getLayoutParams().width = errorStateImageWidth;
    errorStateImageView.getLayoutParams().height = errorStateImageHeight;
    errorStateImageView.requestLayout();
    errorStateTitleTextView.setTextSize(errorStateTitleTextSize);
    errorStateTitleTextView.setTextColor(errorStateTitleTextColor);
    errorStateContentTextView.setTextSize(errorStateContentTextSize);
    errorStateContentTextView.setTextColor(errorStateContentTextColor);
    errorStateButton.setTextColor(errorStateButtonTextColor);
    errorStateButton.getBackground().setColorFilter(new LightingColorFilter(1, errorStateButtonBackgroundColor));
    if (errorStateBackgroundColor != Color.TRANSPARENT) {
      this.setBackgroundColor(errorStateBackgroundColor);
    }
    LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
        ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.gravity = Gravity.CENTER;
    addView(errorState, layoutParams);
  } else {
    errorState.setVisibility(VISIBLE);
  }
}

代码示例来源:origin: vlonjatg/progress-activity

errorStateImageView.requestLayout();

代码示例来源:origin: andforce/iBeebo

@Override
public void requestLayout() {
  if (mBlockMeasurement && mMeasuredExactly) {
    // Ignore request
  } else {
    super.requestLayout();
  }
}

代码示例来源:origin: wuyr/PathLayoutManager

private void initCardHolder(ViewHolder holder) {
  holder.imageView.setVisibility(View.VISIBLE);
  holder.imageView2.setImageBitmap(null);
  holder.imageView2.setVisibility(View.GONE);
  holder.imageView.getLayoutParams().width = 360;
  holder.imageView.requestLayout();
  holder.imageView.setImageBitmap(getBitmap(mRandom.nextInt(3)));
}

代码示例来源:origin: wuyr/PathLayoutManager

private void initJ20Holder(ViewHolder holder) {
  holder.imageView2.setVisibility(View.VISIBLE);
  holder.imageView.setImageBitmap(null);
  holder.imageView.setVisibility(View.GONE);
  holder.imageView2.getLayoutParams().width = 180;
  holder.imageView2.requestLayout();
  holder.imageView2.setImageBitmap(getBitmap(3));
}

代码示例来源:origin: TakuSemba/CropMe

@Override
public void setUri(Uri uri) {
  ImageView image = findViewById(R.id.cropme_image_view);
  image.setImageURI(uri);
  image.requestLayout();
}

代码示例来源:origin: SwiftyWang/FingerColoring-Android

@Override
  public void changeBorder(int drawableid, int pt, int pd, int pl, int pr) {
    if (drawableid != 0) {
      border.setBackgroundResource(drawableid);
      currentImage.setPadding(pl, pt, pr, pd);
      currentImage.requestLayout();
    }
    paintview.requestLayout();
  }
};

相关文章

ImageView类方法