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

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

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

ImageView.getLayoutParams介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

ImageView imgView = (ImageView) findViewById(R.id.pageImage);
imgView.getLayoutParams().height = 200;

代码示例来源:origin: stackoverflow.com

ImageView imageView = (ImageView)findViewById(R.id.news_image);
LinearLayout.LayoutParams lp =
        (LinearLayout.LayoutParams) imageView.getLayoutParams();

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

private int getHeaderViewHeight() {
 return mHeaderView.getLayoutParams().height;
}

代码示例来源:origin: stackoverflow.com

ImageView imageView = findViewById(R.id.dl_image);
LayoutParams params = (LayoutParams) imageView.getLayoutParams();
params.width = 120;
// existing height is ok as is, no need to edit it
imageView.setLayoutParams(params);

代码示例来源:origin: stackoverflow.com

ImageView icon = (ImageView) findViewById(android.R.id.home);
FrameLayout.LayoutParams iconLp = (FrameLayout.LayoutParams) icon.getLayoutParams();
iconLp.topMargin = iconLp.bottomMargin = 0;
icon.setLayoutParams( iconLp );

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

@Override public void onAnimationUpdate(ValueAnimator animation) {
  if (mHeaderView.getLayoutParams().height == mHeaderViewHeight) { // 停止动画,防止快速上划松手后动画产生抖动
   animation.cancel();
  } else {
   setHeaderViewHeight((Integer) animation.getAnimatedValue());
  }
 }
});

代码示例来源:origin: tyzlmjj/PagerBottomTabStrip

/**
 * 设置是否隐藏文字
 */
public void setHideTitle(boolean hideTitle) {
  mHideTitle = hideTitle;
  LayoutParams iconParams = (LayoutParams) mIcon.getLayoutParams();
  if (mHideTitle) {
    iconParams.topMargin = mTopMarginHideTitle;
  } else {
    iconParams.topMargin = mTopMargin;
  }
  mLabel.setVisibility(mChecked ? View.VISIBLE : View.INVISIBLE);
  mIcon.setLayoutParams(iconParams);
}

代码示例来源:origin: lipangit/JiaoZiVideoPlayer

public void changeStartButtonSize(int size) {
  ViewGroup.LayoutParams lp = startButton.getLayoutParams();
  lp.height = size;
  lp.width = size;
  lp = loadingProgressBar.getLayoutParams();
  lp.height = size;
  lp.width = size;
}

代码示例来源:origin: bumptech/glide

@Override
protected void setResource(@Nullable T resource) {
 ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
 Drawable result = getDrawable(resource);
 if (layoutParams != null && layoutParams.width > 0 && layoutParams.height > 0) {
  result = new FixedSizeDrawable(result, layoutParams.width, layoutParams.height);
 }
 view.setImageDrawable(result);
}

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

private void headerRest() {
 ValueAnimator animator = ValueAnimator.ofInt(mHeaderView.getLayoutParams().height, mHeaderViewHeight);
 //animator.setStartDelay(60);
 animator.setDuration(300).start();
 animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
  @Override public void onAnimationUpdate(ValueAnimator animation) {
   if (mHeaderView.getLayoutParams().height == mHeaderViewHeight) { // 停止动画,防止快速上划松手后动画产生抖动
    animation.cancel();
   } else {
    setHeaderViewHeight((Integer) animation.getAnimatedValue());
   }
  }
 });
}

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

String getPictureFieldSpecifier() {
  // How big is our image?
  View view = createGraphObjectView(null);
  ImageView picture = (ImageView) view.findViewById(R.id.com_facebook_picker_image);
  if (picture == null) {
    return null;
  }
  // Note: these dimensions are in pixels, not dips
  ViewGroup.LayoutParams layoutParams = picture.getLayoutParams();
  return String.format(Locale.US, "picture.height(%d).width(%d)", layoutParams.height, layoutParams.width);
}

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

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

代码示例来源:origin: liaoinstan/SpringView

@Override
public void onDropAnim(View rootView, int dy) {
  int maxw = DensityUtil.dp2px(45);
  float w = maxw * Math.abs(dy) / rootView.getMeasuredHeight();
  if (w > maxw) return;
  ViewGroup.LayoutParams layoutParams = header_img.getLayoutParams();
  layoutParams.width = (int) w;
  header_img.setLayoutParams(layoutParams);
}

代码示例来源:origin: android-hacker/VirtualXposed

public View getView(int position, View convertView, ViewGroup parent) {
  View view;
  if (convertView == null) {
    view = mInflater.inflate(R.layout.resolve_list_item, parent, false);
    final ViewHolder holder = new ViewHolder(view);
    view.setTag(holder);
    // Fix the icon size even if we have different sized resources
    ViewGroup.LayoutParams lp = holder.icon.getLayoutParams();
    lp.width = lp.height = mIconSize;
  } else {
    view = convertView;
  }
  bindView(view, mList.get(position));
  return view;
}

代码示例来源:origin: jaydenxiao2016/AndroidFire

@Override
  public void onGlobalLayout() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
      iv.getViewTreeObserver().removeOnGlobalLayoutListener(this);
    } else {
      iv.getViewTreeObserver().removeGlobalOnLayoutListener(this);
    }
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) iv.getLayoutParams();
    params.height = params.width;
    iv.setLayoutParams(params);
    iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
  }
});

代码示例来源:origin: androidquery/androidquery

private int getWidth(ImageView iv){
  
  int width = 0;
  
  LayoutParams lp = iv.getLayoutParams();
  if(lp != null) width = lp.width;
  
  if(width <= 0){
    width = iv.getWidth();
  }
  
  if(width > 0){
    width = width - iv.getPaddingLeft() - iv.getPaddingRight();
  }
  
  return width;
}

代码示例来源:origin: androidquery/androidquery

private void adjust(ImageView iv, Bitmap bm, boolean done){
  
  int vw = getWidth(iv);
  if(vw <= 0) return;
  
  int dw = bm.getWidth();
  int dh = bm.getHeight();
  
  
  int th = targetHeight(dw, dh, vw) + iv.getPaddingTop() + iv.getPaddingBottom();
    
  LayoutParams lp = iv.getLayoutParams();
  if(lp == null) return;
  
  int vh = lp.height;
  
  
  if(th != vh){
    
    lp.height = th;
    iv.setLayoutParams(lp);
        
  }
  
  if(done) adjusted = true;	
}

代码示例来源:origin: andkulikov/Transitions-Everywhere

@Override
  public void onClick(View v) {
    mExpanded = !mExpanded;
    TransitionManager.beginDelayedTransition(transitionsContainer, new TransitionSet()
      .addTransition(new ChangeBounds())
      .addTransition(new ChangeImageTransform()));
    ViewGroup.LayoutParams params = imageView.getLayoutParams();
    params.height = mExpanded ? ViewGroup.LayoutParams.MATCH_PARENT : ViewGroup.LayoutParams.WRAP_CONTENT;
    imageView.setLayoutParams(params);
    imageView.setScaleType(mExpanded ? ImageView.ScaleType.CENTER_CROP : ImageView.ScaleType.FIT_CENTER);
  }
});

代码示例来源:origin: robolectric/robolectric

@Test
@Config(minSdk = JELLY_BEAN_MR1)
public void getRules_shouldShowAddRuleData_sinceApiLevel17() throws Exception {
 ImageView imageView = new ImageView(ApplicationProvider.getApplicationContext());
 RelativeLayout layout = new RelativeLayout(ApplicationProvider.getApplicationContext());
 layout.addView(imageView, new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
 RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
 layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
 layoutParams.addRule(RelativeLayout.ALIGN_TOP, 1234);
 int[] rules = layoutParams.getRules();
 assertThat(rules).isEqualTo(new int[]{0, 0, 0, 0, 0, 0, 1234, 0, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0});
}

代码示例来源:origin: robolectric/robolectric

@Test
 @Config(maxSdk = JELLY_BEAN)
 public void getRules_shouldShowAddRuleData_uptoApiLevel16() throws Exception {
  ImageView imageView = new ImageView(ApplicationProvider.getApplicationContext());
  RelativeLayout layout = new RelativeLayout(ApplicationProvider.getApplicationContext());
  layout.addView(imageView, new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
  RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) imageView.getLayoutParams();
  layoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
  layoutParams.addRule(RelativeLayout.ALIGN_TOP, 1234);
  int[] rules = layoutParams.getRules();
  assertThat(rules).isEqualTo(new int[]{0, 0, 0, 0, 0, 0, 1234, 0, 0, 0, 0, -1, 0, 0, 0, 0});
 }
}

相关文章

ImageView类方法