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

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

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

ImageView.setMaxWidth介绍

暂无

代码示例

代码示例来源:origin: Flipboard/bottomsheet

thumb.setMinimumHeight(thumbnailSize);
thumb.setMaxHeight(thumbnailSize);
thumb.setMaxWidth(thumbnailSize);
if (tile.imageUri != null) {
  imageProvider.onProvideImage(thumb, tile.imageUri, thumbnailSize);

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

channelIcon.setAdjustViewBounds(true);
channelIcon.setMaxHeight(30);
channelIcon.setMaxWidth(30);
channelIcon.setImageDrawable(o.getLogo());

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

mImagePreview.setMaxWidth((int) Math.round(width * 0.6));

代码示例来源: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: stackoverflow.com

LinearLayout layout = (LinearLayout)findViewById(R.id.imageLayout);
for(int i=0;i<10;i++)
{
  ImageView image = new ImageView(this);
  image.setLayoutParams(new android.view.ViewGroup.LayoutParams(80,60));
  image.setMaxHeight(20);
  image.setMaxWidth(20);

  // Adds the view to the layout
  layout.addView(image);
}

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

ImageView imgView = new ImageView(activityContext);
LinearLayout.LayoutParams vp = new LinearLayout.LayoutParams
             (LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
imgView.setLayoutParams(vp);
imgView.setMaxHeight(100);
imgView.setMaxWidth(100);
imgView.setImageURI(Uri.parse(captureImg.toString()));
mainFrame.addView(imgView);

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

LinearLayout layout = (LinearLayout)findViewById(R.id.imageLayout);
for(int i=0;i<5;i++)
{
  ImageView image = new ImageView(this);
  image.setLayoutParams(new android.view.ViewGroup.LayoutParams(80,60));
  image.setMaxHeight(10);
  image.setMaxWidth(10);

  // Adds the view to the Linerlayout
  layout.addView(image);
}

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

ImageView image = new ImageView(this);
LinearLayout.LayoutParams vp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
image.setLayoutParams(vp);
image.setMaxHeight(50);
image.setMaxWidth(50);
// other image settings
image.setImageDrawable(drawable);
theLayout.addView(image);

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

ImageView image = new ImageView(this);
LinearLayout.LayoutParams vp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
image.setLayoutParams(vp);
image.setMaxHeight(50);
image.setMaxWidth(50);
// other image settings
image.setImageDrawable(drawable);
theLayout.addView(image);

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

ImageView img1=(ImageView) findViewById(R.id.imageview);
 img1.setMaxHeight(100);
 img1.setMaxWidth(100);

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

final ImageView imageView = new ImageView(context);
final LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(150, 200);
params.weight = 1;
imageView.setLayoutParams(params);
imageView.setMaxHeight(200);
imageView.setMaxWidth(150);

new DownloadImageTask(imageView, layout).execute(tempValues.getItemAbsolutePath());

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

ImageView imageView = (ImageView) findViewById(R.id.imageView);
   imageView.setAdjustViewBounds(true);
   imageView.setMaxHeight(imageView.getHeight());
   imageView.setMaxWidth(imageView.getWidth());
   imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
   imageView.setImageBitmap(BitmapFactory.decodeFile(picturePath));

代码示例来源:origin: Tencent/RapidView

public void run(RapidParserObject object, Object view, Var value) {
    int width = 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;
      width = (int)(percent * object.mScreenWidth);
    }
    else if( str.length() >= 2 && str.substring(str.length() - 2).compareToIgnoreCase("%x") == 0 ){
      float percent = Float.parseFloat(str.substring(0, str.length() - 2)) / 100;
      width = (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;
      width = (int)(percent * object.mScreenHeight);
    }
    else{
      width = ViewUtils.dip2px(object.mContext, value.getFloat());
    }
    ((ImageView)view).setMaxWidth(width);
  }
}

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

InputStream is = null;
String inputurl = " Enter url of ur image ";
try {
    URL url = new URL(inputurl);
    Object content = url.getContent();
    is = (InputStream) content;
    avatar = Drawable.createFromStream(is,"src");
} catch (MalformedURLException e) {
    e.printStackTrace();
} catch (IOException e) {
    e.printStackTrace();
}

ImageView image = new ImageView(this);
LinearLayout.LayoutParams vp = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
image.setLayoutParams(vp);
image.setScaleType(ImageView.ScaleType.CENTER_CROP);
image.setMaxHeight(50);
image.setMaxWidth(50);
image.setImageDrawable(avatar);
theLayout.addView(image);

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

public class MyClass {
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

    // Do your other stuff here

    MenuItem item = menu.getItem(0);

    if (item.getItemId() == R.id.action_example) {
      ImageView imageView = new ImageView(getActivity());
      imageView.setMaxHeight(18);
      imageView.setMaxWidth(18);
      imageView.setImageResource(R.drawable.barchart32);

      item.setActionView(imageView);
    }
  }
}

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

public ImageView getCardView(String Card){
   ImageView imageView = new ImageView(this);
   switch(Card){
     case "joker-one": 
       imageView.setImageResource(R.drawable.jokerone);
       imageView.setMaxHeight(20);
       imageView.setMaxWidth(10);
       imageView.setId(1);
     break; 
     default: 
       imageView.setImageResource(R.drawable.kingdiamonds);
       imageView.setMaxHeight(20);
       imageView.setMaxWidth(10);
       imageView.setId(2);
     break; 
   } 
   return imageView;
 }

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

first you should convert Textview to imageview.Next you should apply sample image view drag functionality.
 -----------------------------
     TextView tv = new TextView(this);
     FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
         FrameLayout.LayoutParams.FILL_PARENT,
         FrameLayout.LayoutParams.FILL_PARENT);
     tv.setLayoutParams(layoutParams);
     tv.setText("Text");
     tv.setTextColor(Color.BLACK);
     tv.setBackgroundColor(Color.TRANSPARENT);
     Bitmap testB;
     testB = Bitmap.createBitmap(80, 100, Bitmap.Config.ARGB_8888);
     Canvas c = new Canvas(testB);
     tv.layout(30, 40, 200, 100);
     tv.draw(c);
     ImageView iv = (ImageView) findViewById(R.id.imageView);
     iv.setLayoutParams(layoutParams);
     iv.setBackgroundColor(Color.GRAY);`enter code here`
     iv.setImageBitmap(testB);
     iv.setMaxHeight(80);
     iv.setMaxWidth(200);
     iv.setOnTouchListener(this);

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

@Override
 public void onCreate(Bundle savedInstanceState)
 {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   TextView tv = new TextView(this);
   LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(80, 100);
   tv.setLayoutParams(layoutParams);
   tv.setText("testing 1 2 3");
   tv.setTextColor(Color.BLACK);
   tv.setBackgroundColor(Color.TRANSPARENT);
   Bitmap testB;
   testB = Bitmap.createBitmap(80, 100, Bitmap.Config.ARGB_8888);
   Canvas c = new Canvas(testB);
   tv.layout(0, 0, 80, 100);
   tv.draw(c);
   ImageView iv = (ImageView)findViewById(R.id.menuIcon);
   iv.setLayoutParams(layoutParams);
   iv.setBackgroundColor(Color.GRAY);
   iv.setImageBitmap(testB);
   iv.setMaxHeight(80);
   iv.setMaxWidth(80);
 }

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

private View createIcon(GridLayout parent, int rowIndex) {
    // The icon has a pre-defined width.
    ImageView icon = new ImageView(parent.getContext());
    icon.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
    icon.setBackgroundResource(R.drawable.payments_ui_logo_bg);
    icon.setImageResource(mOption.getDrawableIconId());
    icon.setMaxWidth(mIconMaxWidth);
    // The icon floats to the right of everything.
    GridLayout.LayoutParams iconParams = new GridLayout.LayoutParams(
        GridLayout.spec(rowIndex, 1, GridLayout.CENTER), GridLayout.spec(2, 1));
    iconParams.topMargin = mVerticalMargin;
    ApiCompatibilityUtils.setMarginStart(iconParams, mLargeSpacing);
    parent.addView(icon, iconParams);
    icon.setOnClickListener(OptionSection.this);
    return icon;
  }
}

相关文章

ImageView类方法