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

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

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

ImageView.setAdjustViewBounds介绍

暂无

代码示例

代码示例来源:origin: bm-x/PhotoView

@Override
public void setAdjustViewBounds(boolean adjustViewBounds) {
  super.setAdjustViewBounds(adjustViewBounds);
  mAdjustViewBounds = adjustViewBounds;
}

代码示例来源:origin: Hitomis/transferee

@Override
public void setAdjustViewBounds(boolean adjustViewBounds) {
  super.setAdjustViewBounds(adjustViewBounds);
  mAdjustViewBounds = adjustViewBounds;
}

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

//NOTE: "this" is a subclass of LinearLayout
ImageView splashImageView = new ImageView(context);
splashImageView.setImageResource(R.drawable.splash);
splashImageView.setAdjustViewBounds(true);
addView(splashImageView);

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

Resources res = getResources();
ScaleDrawable sd = (ScaleDrawable) res.getDrawable(R.drawable.logo2);
Drawable d = sd.getDrawable();

d.setLevel(1);

ImageView iv = new ImageView(this);
iv.setImageDrawable(sd);
iv.setAdjustViewBounds(true); 
iv.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

setContentView(iv);

代码示例来源:origin: mikepenz/FastAdapter

public ViewHolder(View view) {
    super(view);
    ButterKnife.bind(this, view);
    this.view = view;
    //optimization to preset the correct height for our device
    int columns = view.getContext().getResources().getInteger(R.integer.wall_splash_columns);
    int screenWidth = view.getContext().getResources().getDisplayMetrics().widthPixels;
    int finalHeight = (int) (screenWidth / 1.5);
    imageView.setMinimumHeight(finalHeight / columns);
    imageView.setMaxHeight(finalHeight / columns);
    imageView.setAdjustViewBounds(false);
    //set height as layoutParameter too
    FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) imageView.getLayoutParams();
    lp.height = finalHeight / columns;
    imageView.setLayoutParams(lp);
  }
}

代码示例来源:origin: mikepenz/FastAdapter

public ViewHolder(View view) {
    super(view);
    ButterKnife.bind(this, view);
    this.view = (FrameLayout) view;
    //optimization to preset the correct height for our device
    int screenWidth = view.getContext().getResources().getDisplayMetrics().widthPixels;
    int finalHeight = (int) (screenWidth / 1.5) / 2;
    imageView.setMinimumHeight(finalHeight);
    imageView.setMaxHeight(finalHeight);
    imageView.setAdjustViewBounds(false);
    //set height as layoutParameter too
    FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) imageView.getLayoutParams();
    lp.height = finalHeight;
    imageView.setLayoutParams(lp);
  }
}

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

ImageView imageView = new ImageView(this);
imageView.setImageBitmap(yourbitmap);
imageView.setAdjustViewBounds(true);
lnrImages.addView(imageView);

代码示例来源:origin: navasmdc/MaterialDesignLibrary

public ButtonFloat(Context context, AttributeSet attrs) {
  super(context, attrs);
  setBackgroundResource(R.drawable.background_button_float);
  setBackgroundColor(backgroundColor);
  sizeRadius = 28;
  setDefaultProperties();
  icon = new ImageView(context);
  icon.setAdjustViewBounds(true);
  icon.setScaleType(ScaleType.CENTER_CROP);
  if(drawableIcon != null) {
    icon.setImageDrawable(drawableIcon);
  }
  LayoutParams params = new LayoutParams(Utils.dpToPx(sizeIcon, getResources()),Utils.dpToPx(sizeIcon, getResources()));
  params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
  icon.setLayoutParams(params);
  addView(icon);        
  
}

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

private ImageView createImageView(int position, final boolean isMultiImage) {
  String url = imagesList.get(position);
  ImageView imageView = new ColorFilterImageView(getContext());
  if(isMultiImage){
    imageView.setScaleType(ScaleType.CENTER_CROP);
    imageView.setLayoutParams(position % MAX_PER_ROW_COUNT == 0 ?moreParaColumnFirst : morePara);
  }else {
    imageView.setAdjustViewBounds(true);
    imageView.setScaleType(ScaleType.CENTER_CROP);
    imageView.setMaxHeight(pxOneMaxWandH);
    imageView.setLayoutParams(onePicPara);
  }
  imageView.setTag(R.string.zone_img_position,position);
  imageView.setId(url.hashCode());
  imageView.setOnClickListener(mImageViewOnClickListener);
  ImageLoaderUtils.display(getContext(), imageView, ImageUtil.getImageUrl(url));
  return imageView;
}

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

channelIcon.setAdjustViewBounds(true);
channelIcon.setMaxHeight(30);
channelIcon.setMaxWidth(30);

代码示例来源:origin: Naoki2015/CircleDemo

imageView.setLayoutParams(position % MAX_PER_ROW_COUNT == 0 ?moreParaColumnFirst : morePara);
}else {
  imageView.setAdjustViewBounds(true);
  imageView.setScaleType(ScaleType.CENTER_INSIDE);

代码示例来源:origin: ankidroid/Anki-Android

setPreviewImage(mField.getImagePath(), getMaxImageSize());
mImagePreview.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
mImagePreview.setAdjustViewBounds(true);

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

isImageFitToScreen=false;
  imageView.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
  imageView.setAdjustViewBounds(true);
}else{
  isImageFitToScreen=true;

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

// obtain action bar
ActionBar actionBar = getSupportActionBar();

// find SearchView (im my case it's in a custom layout because of left alignment)
View v = actionBar.getCustomView();
SearchView searchView = (SearchView)v.findViewById(R.id.search_view);
ImageView icon = (ImageView)searchView.findViewById(android.support.v7.appcompat.R.id.search_mag_icon);

// method 1: does not work persistently, because the next line
// should be probably called after every manipulation with SearchView
// icon.setVisibility(View.GONE);

// method 2: working code
icon.setAdjustViewBounds(true);
icon.setMaxWidth(0);
icon.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
icon.setImageDrawable(null);

代码示例来源:origin: weexteam/weex-hackernews

@Override
public void onException(NestedContainer container, String errCode, String msg) {
 if (TextUtils.equals(errCode, WXRenderErrorCode.WX_NETWORK_ERROR) && container instanceof WXEmbed) {
  final WXEmbed comp = ((WXEmbed)container);
  final ImageView imageView = new ImageView(comp.getContext());
  imageView.setImageResource(R.drawable.error);
  FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ERROR_IMG_WIDTH, ERROR_IMG_HEIGHT);
  layoutParams.gravity = Gravity.CENTER;
  imageView.setLayoutParams(layoutParams);
  imageView.setScaleType(ImageView.ScaleType.FIT_XY);
  imageView.setAdjustViewBounds(true);
  imageView.setOnClickListener(new View.OnClickListener() {
   @Override
   public void onClick(View v) {
    imageView.setOnClickListener(null);
    imageView.setEnabled(false);
    comp.loadContent();
   }
  });
  FrameLayout hostView = comp.getHostView();
  hostView.removeAllViews();
  hostView.addView(imageView);
  WXLogUtils.e("WXEmbed", "NetWork failure :" + errCode + ",\n error message :" + msg);
 }
}

代码示例来源:origin: flipkart-incubator/proteus

@Override
 public void setString(T view, String value) {
  if ("true".equals(value)) {
   view.setAdjustViewBounds(true);
  } else {
   view.setAdjustViewBounds(false);
  }
 }
});

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

Drawable logo = getDrawable(iconRes);
 toolbar.setLogo(logo);
 for (int i = 0; i < toolbar.getChildCount(); i++) {
  View child = toolbar.getChildAt(i);
  if (child != null)
   if (child.getClass() == ImageView.class) {
    ImageView iv2 = (ImageView) child;
    if ( iv2.getDrawable() == logo ) {
     iv2.setAdjustViewBounds(true);
    }
   }
 }

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

ImageView imageView=new ImageView(context);
 imageView.setAdjustViewBounds(true);
 imageView.setImageBitmap(bitmap);
 imageView.setMaxHeight(maxHeight);
 imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
 layout.addView(imageView);

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

ImageView i = new ImageView(mContext);
Drawable d = null;
i.setImageDrawable(d);
    i.setAdjustViewBounds(true);
    i.setScaleType(ScaleType.CENTER_INSIDE);
    i.setBackgroundColor(Color.WHITE); //providing color to the background. 
    i.setPadding(3,3,3,3);//providing padding to the image.
    i.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

代码示例来源:origin: mylhyl/Android-CircleDialog

private void init() {
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,
        LayoutParams.WRAP_CONTENT);
    mImageView = new ImageView(getContext());
    mImageView.setId(android.R.id.icon);
    mImageView.setImageResource(mAdParams.imageResId);
    mImageView.setAdjustViewBounds(true);
    addView(mImageView, layoutParams);
  }
}

相关文章

ImageView类方法