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

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

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

ImageView.setMinimumHeight介绍

暂无

代码示例

代码示例来源:origin: TeamNewPipe/NewPipe

private void setHeightThumbnail() {
  final DisplayMetrics metrics = getResources().getDisplayMetrics();
  boolean isPortrait = metrics.heightPixels > metrics.widthPixels;
  int height = isPortrait
      ? (int) (metrics.widthPixels / (16.0f / 9.0f))
      : (int) (metrics.heightPixels / 2f);
  thumbnailImageView.setLayoutParams(
      new FrameLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, height));
  thumbnailImageView.setMinimumHeight(height);
}

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

//byte[] chartData 
   ImageView imgViewer = (ImageView) findViewById(R.id.chart_image);
   Bitmap bm = BitmapFactory.decodeByteArray(chartData, 0, chartData.length);
   DisplayMetrics dm = new DisplayMetrics();
   getWindowManager().getDefaultDisplay().getMetrics(dm);
   imgViewer.setMinimumHeight(dm.heightPixels);
   imgViewer.setMinimumWidth(dm.widthPixels);
   imgViewer.setImageBitmap(bm);

代码示例来源: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: Flipboard/bottomsheet

thumb.setMinimumHeight(thumbnailSize);
thumb.setMaxHeight(thumbnailSize);
thumb.setMaxWidth(thumbnailSize);

代码示例来源:origin: scwang90/SmartRefreshLayout

@NonNull
  @Override
  public SmartViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    FlexboxLayoutManager.LayoutParams lp = new FlexboxLayoutManager.LayoutParams(-2,-2);
    lp.setFlexGrow(1);
    lp.bottomMargin = DensityUtil.dp2px(2.5f);
    lp.topMargin = DensityUtil.dp2px(2.5f);
    lp.leftMargin = DensityUtil.dp2px(2.5f);
    lp.rightMargin = DensityUtil.dp2px(2.5f);
    ImageView imageVIew = new ImageView(parent.getContext());
    imageVIew.setMinimumWidth(DensityUtil.dp2px(90f));
    imageVIew.setMinimumHeight(DensityUtil.dp2px(90f));
    imageVIew.setLayoutParams(lp);
    return new SmartViewHolder(imageVIew, mListener);
  }
});

代码示例来源:origin: jiangqqlmj/FastDev4Android

mRefreshViewImage.setMinimumHeight(50); //设置下拉最小的高度为50

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

@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
  View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_movie, parent, false);
  ImageView viewById = (ImageView) view.findViewById(R.id.poster);
  viewById.setMinimumWidth(newWidth);
  viewById.setMinimumHeight(newHeight);
  return new ViewHolder(view);
}

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

convertView.setMinimumHeight(parent.getMeasuredHeight());
ImageView slika=(ImageView)v.findViewById(R.id.imageView_obj);    
slika.setMinimumHeight(parent.getMeasuredHeight());
TextView xx=(TextView)v.findViewById(R.id.xx);
xx.setHeight(parent.getMeasuredHeight());

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

ImageView imgViewer = (ImageView) findViewById(id.of.your.img_viewer);
Bitmap bm = BitmapFactory.decodeByteArray(data, 0, data.length);
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);

imgViewer.setMinimumHeight(dm.heightPixels);
imgViewer.setMinimumWidth(dm.widthPixels);
imgViewer.setImageBitmap(bm);

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

ImageView bmImage = (ImageView)this.findViewById(R.id.MyImage);
String urldisplay = urls[0];
    Bitmap mIcon11 = null;
    try {
      InputStream in = new java.net.URL(urldisplay).openStream();
      mIcon11 = BitmapFactory.decodeStream(in);
    } catch (Exception e) {
      Log.e("Error", e.getMessage());
      e.printStackTrace();
    }

 bmImage.setImageBitmap(mIcon11);
 if(mIcon11 != null){
  int width = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, mIcon11.getWidth(), this.getResources().getDisplayMetrics());
  int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, mIcon11.getHeight(), this.getResources().getDisplayMetrics());

  bmImage.setMinimumWidth(width);
  bmImage.setMinimumHeight(height);
 }

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

this.menu = menu;
this.menu.add("calendar");
ImageView imageView = new ImageView(getActivity());
imageView.setMinimumHeight(128);
imageView.setMinimumWidth(128);
imageView.setImageDrawable(yourDrawable);
MenuItem item = this.menu.getItem(0);
item.setActionView(imageView);

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

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: Tencent/RapidView

public void run(RapidParserObject object, Object view, Var value) {
    int height = 0;
    String str = value.getString();
    if( str.length() >= 1 && str.substring(str.length() - 1).compareToIgnoreCase("%") == 0 ){
      float percent = Float.parseFloat(str.substring(0, str.length() - 1)) / 100;
      height = (int)(percent * object.mScreenHeight);
    }
    else if( str.length() >= 2 && str.substring(str.length() - 2).compareToIgnoreCase("%x") == 0 ){
      float percent = Float.parseFloat(str.substring(0, str.length() - 2)) / 100;
      height = (int)(percent * object.mScreenWidth);
    }
    else if( str.length() >= 2 && str.substring(str.length() - 2).compareToIgnoreCase("%y") == 0 ){
      float percent = Float.parseFloat(str.substring(0, str.length() - 2)) / 100;
      height = (int)(percent * object.mScreenHeight);
    }
    else{
      height = ViewUtils.dip2px(object.mContext, value.getFloat());
    }
    ((ImageView)view).setMinimumHeight(height);
  }
}

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

Private Menu menu
  @Override
   public boolean onCreateOptionsMenu(Menu menu) {
     // Inflate the menu; this adds items to the action bar if it is present.
     getMenuInflater().inflate(R.menu.main, menu);
     this.menu = menu;
     ImageView imageView = new ImageView(getActivity());
     imageView.setMinimumHeight(128);
     imageView.setMinimumWidth(128);
     imageView.setImageDrawable(yourDrawable);
     MenuItem item = this.menu.getItem(0);
     item.setActionView(imageView);
     return true;
   }

代码示例来源:origin: omadahealth/SlidePager

/**
 * Init the {@link android.graphics.Color} of the {@link #mChartBarList}
 */
private void initBarColorsAndSize() {
  for (ImageView imageView : mChartBarList) {
    imageView.setBackgroundColor(mChartBarColor);
    if (imageView.getId() != R.id.progress_bottom_axis) {
      imageView.setMinimumHeight((int) (mChartBarSize / 2.0f));
    }
  }
}

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

//http://stackoverflow.com/questions/4605527/converting-pixels-to-dp
public static float convertDpToPixel(float dp, Context context){
  Resources resources = context.getResources();
  DisplayMetrics metrics = resources.getDisplayMetrics();
  float px = dp * (metrics.densityDpi / 160f);
  return px;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);//loads the xml above

  ImageView v = (ImageView) findViewById(R.id.imageView);
  int dp = 200;
  int px = (int) convertDpToPixel(dp, this);
  v.setMaxHeight(px);//no need for it
  v.setMinimumHeight(px);//should do more or less the same as next line
  v.setLayoutParams(new LinearLayout.LayoutParams(px, px));//is like android:layout_width="200dp" android:layout_height="200dp"
  v.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, px));//is like android:layout_width="wrap_content" android:layout_height="200dp"
  //basically you can do the same with the TextView + the Text styling
  TextView tv = (TextView) findViewById(R.id.textView);
  tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 50);
  tv.setPadding(30,30,30,30);//don't forget, this is also px so you may need dp to px conversion
}

代码示例来源:origin: bitstadium/HockeySDK-Android

private void configureViewForPlaceholder(final boolean openOnClick) {
  mTextView.setMaxWidth(mWidthPortrait);
  mTextView.setMinWidth(mWidthPortrait);
  mImageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams
      .WRAP_CONTENT));
  mImageView.setAdjustViewBounds(false);
  mImageView.setBackgroundColor(Color.parseColor("#eeeeee"));
  mImageView.setMinimumHeight((int) (mWidthPortrait * 1.2f));
  mImageView.setMinimumWidth(mWidthPortrait);
  mImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
  mImageView.setImageDrawable(getSystemIcon("ic_menu_attachment"));
  mImageView.setContentDescription(mTextView.getText());
  mImageView.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
      if (!openOnClick) {
        return;
      }
      Intent intent = new Intent();
      intent.setAction(Intent.ACTION_VIEW);
      intent.setDataAndType(mAttachmentUri, "*/*");
      mContext.startActivity(intent);
    }
  });
}

代码示例来源:origin: NimbleDroid/FriendlyDemo

private void setupThumbnail(int targetWidth, int targetHeight) {
  thumbnail.setMaxWidth(targetWidth);
  thumbnail.setMaxHeight(targetHeight);
  thumbnail.setMinimumWidth(targetWidth);
  thumbnail.setMinimumHeight(targetHeight);
  thumbnail.requestLayout();
}

代码示例来源:origin: lucid-lynxz/BlogSamples

public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  this.mIVLightBox = new PhotoView(inflater.getContext());
  this.mIVLightBox.setLayoutParams(new ViewGroup.LayoutParams(-1, -2));
  Bitmap bitmap = ((URLDrawableProxy)this.mImageSpan.getDrawable()).getBitmapResource();
  Context ctx = inflater.getContext();
  int width = MixedUtils.dpToPx(ctx, (float)(bitmap.getWidth() << 1));
  int height = MixedUtils.dpToPx(ctx, (float)(bitmap.getHeight() << 1));
  BitmapDrawable drawable = new BitmapDrawable(this.getResources(), bitmap);
  drawable.setBounds(0, 0, width, height);
  int[] size = MixedUtils.getScreenDimention(inflater.getContext());
  size = this.resetSize(size, width, height);
  this.mIVLightBox.setMinimumWidth(size[0] - MixedUtils.dpToPx(ctx, 16.0F));
  this.mIVLightBox.setMinimumHeight(size[1]);
  this.mIVLightBox.setImageDrawable(drawable);
  return this.mIVLightBox;
}

相关文章

ImageView类方法