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

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

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

ImageView.setPadding介绍

暂无

代码示例

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

LinearLayout layout = (LinearLayout) findViewById(R.id.linear);
 for (int i = 0; i < 10; i++) {
   ImageView imageView = new ImageView(this);
   imageView.setId(i);
   imageView.setPadding(2, 2, 2, 2);
   imageView.setImageBitmap(BitmapFactory.decodeResource(
       getResources(), R.drawable.ic_launcher));
   imageView.setScaleType(ScaleType.FIT_XY);
   layout.addView(imageView);
 }

代码示例来源:origin: medyo/Fancybuttons

/**
 * Text Icon resource view
 *
 * @return : ImageView
 */
private ImageView setupIconView() {
  if (mIconResource != null) {
    ImageView iconView = new ImageView(mContext);
    iconView.setImageDrawable(mIconResource);
    iconView.setPadding(mIconPaddingLeft, mIconPaddingTop, mIconPaddingRight, mIconPaddingBottom);
    LayoutParams iconViewParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    if (mTextView != null) {
      if (mIconPosition == POSITION_TOP || mIconPosition == POSITION_BOTTOM)
        iconViewParams.gravity = Gravity.CENTER;
      else
        iconViewParams.gravity = Gravity.START;
      iconViewParams.rightMargin = 10;
      iconViewParams.leftMargin = 10;
    } else {
      iconViewParams.gravity = Gravity.CENTER_VERTICAL;
    }
    iconView.setLayoutParams(iconViewParams);
    return iconView;
  }
  return null;
}

代码示例来源:origin: dinuscxj/RecyclerRefreshLayout

public DefaultTipsHelper(RecyclerFragment<?> fragment) {
  mFragment = fragment;
  mRecyclerView = fragment.getRecyclerView();
  mRefreshLayout = fragment.getRecyclerRefreshLayout();
  mLoadingView = new ImageView(fragment.getActivity());
  mLoadingView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
  mLoadingView.setImageResource(R.drawable.spinner);
  mLoadingView.setPadding(0, (int) DensityUtil.dip2px(mFragment.getActivity(), 10),
      0, (int) DensityUtil.dip2px(mFragment.getActivity(), 10));
  mLoadingView.setLayoutParams(new RecyclerView.LayoutParams(
      RecyclerRefreshLayout.LayoutParams.MATCH_PARENT,
      (int) DensityUtil.dip2px(fragment.getActivity(), 40)));
}

代码示例来源:origin: pili-engineering/PLDroidShortVideo

@Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ImageView imageView;
    if (convertView == null) {
      imageView = new ImageView(mContext);
      imageView.setLayoutParams(new GridView.LayoutParams(300, 300));
      imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
      imageView.setPadding(8, 8, 8, 8);
    } else {
      imageView = (ImageView) convertView;
    }
    imageView.setTag(position);
    imageView.setImageDrawable(null);
    imageView.setBackgroundColor(getResources().getColor(mSelectedFrameIndex.contains(position) ? R.color.colorAccent : R.color.white));
    Bitmap cached = mBitmapCache.get(position);
    if (cached != null) {
      imageView.setImageBitmap(cached);
    } else {
      LoadFrameTask task = mOngoingTasks.get(position);
      if (task != null && task.getStatus() == AsyncTask.Status.RUNNING) {
        task.cancel(true);
      }
      task = new LoadFrameTask(position, imageView);
      mOngoingTasks.put(position, task);
      task.execute();
    }
    return imageView;
  }
}

代码示例来源:origin: googlemaps/android-maps-utils

public PersonRenderer() {
  super(getApplicationContext(), getMap(), mClusterManager);
  View multiProfile = getLayoutInflater().inflate(R.layout.multi_profile, null);
  mClusterIconGenerator.setContentView(multiProfile);
  mClusterImageView = (ImageView) multiProfile.findViewById(R.id.image);
  mImageView = new ImageView(getApplicationContext());
  mDimension = (int) getResources().getDimension(R.dimen.custom_profile_image);
  mImageView.setLayoutParams(new ViewGroup.LayoutParams(mDimension, mDimension));
  int padding = (int) getResources().getDimension(R.dimen.custom_profile_padding);
  mImageView.setPadding(padding, padding, padding, padding);
  mIconGenerator.setContentView(mImageView);
}

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

mArrowImageView.setPadding(padding, padding, padding, padding);
addView(mArrowImageView);
    mArrowImageView.setScaleType(ScaleType.MATRIX);
    Matrix matrix = new Matrix();
    matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f);

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

public View getView(int arg0, View arg1, ViewGroup arg2) {

  if(arg1!=null)
  {
    ImageView imv = new ImageView(cont);
    imv.setLayoutParams(new GridView.LayoutParams(40,40));
    imv.setScaleType(ScaleType.CENTER_CROP);
    imv.setPadding(0,0,0,0);

    arg1 = imv;
  }
  arg1.setTag(arg0);
  return arg1;
}

代码示例来源:origin: medyo/android-about-page

int size = mContext.getResources().getDimensionPixelSize(R.dimen.about_icon_size);
LinearLayout.LayoutParams iconParams = new LinearLayout.LayoutParams(size, size);
iconView.setLayoutParams(iconParams);
int iconPadding = mContext.getResources().getDimensionPixelSize(R.dimen.about_icon_padding);
iconView.setPadding(iconPadding, 0, iconPadding, 0);

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

ImageView imageView = new ImageView(context);
   int padding = 10;
   imageView.setPadding(padding, padding, padding, padding);
   imageView.setScaleType(ImageView.ScaleType.MATRIX);
   imageView.setImageResource(R.drawable.ic_launcher);
   container.addView(imageView, 0);
   return container;

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

public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;

if (convertView == null) {  
  imageView = new ImageView(mContext);
  imageView.setLayoutParams(new GridView.LayoutParams(300, 250));
  imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
  imageView.setPadding(8, 8, 8, 8);
} else {
  imageView = (ImageView) convertView;
}

imageView.setImageResource(mThumbIds[position]);

return imageView;

代码示例来源:origin: wangdan/AisenWeiBo

imgCover.setLayoutParams(lp);
imgCover.setPadding(0, 0, 0, layDetail.getHeight());

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

public Object instantiateItem(ViewGroup container, int position) {
   RelativeLayout v0 = (RelativeLayout ) inflater.inflate (R.layout.one_of_my_page_layouts, null);
   ImageView imageView = vo.findViewById(R.id.photo_thumb);
   int padding = 10;
   imageView.setPadding(padding, padding, padding, padding);
   imageView.setScaleType(ImageView.ScaleType.MATRIX);
   imageView.setImageResource(GalImages[position]);
   container.addView(v0, 0);
   return v0;
 }

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

@Override
public View getView(int position, View convertView, ViewGroup parent) {
  ImageView imageView = new ImageView(mContext);
  imageView.setImageResource(mThumbIds[position]);
  imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
  imageView.setLayoutParams(new GridView.LayoutParams(
      (int) mContext.getResources().getDimension(R.dimen.width),                                                                                   
      (int) mContext.getResources().getDimension(R.dimen.height)));
  imageView.setPadding(5, 5, 5, 5);
  return imageView;
}

代码示例来源:origin: wangdan/AisenWeiBo

if (lp.height != defHeight + coverHeight) {
  lp.height = defHeight + coverHeight;
  imgCover.setLayoutParams(lp);
  imgCover.setPadding(imgCover.getPaddingLeft(), imgCover.getPaddingTop(), imgCover.getPaddingRight(), defHeight);

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

@Override
public Object instantiateItem(ViewGroup container, int position) {
 ImageView imageView = new ImageView(context);
 int padding = context.getResources().getDimensionPixelSize(R.dimen.padding_small);
 imageView.setPadding(padding, padding, padding, padding);
 imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE  );
 imageView.setImageResource(GalImages[position]);
 ((ViewPager) container).addView(imageView, 0);
 return imageView;
}

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

public View getView(int position, View convertView, ViewGroup parent) {
 ImageView imageView;
 if (convertView == null) {
   imageView = new ImageView(mContext);
   imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
   imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
   imageView.setPadding(8, 8, 8, 8);
 } else {
   imageView = (ImageView) convertView;
 }
 imageView.setImageDrawable(mThumbIds[position]);
 return imageView;
}

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

ImageView imageView = new ImageView(this);
imageView.setImageBitmap(bmp);
imageView.setLayoutParams(params);
imageView.setBackgroundResource(R.drawable.style);
imageView.setPadding(2,2,2,2); // <- try out different values

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

public View getView(int position, View convertView, ViewGroup parent) {
 View v;

 if (convertView == null) {
  v = LayoutInflater.from(mContext).inflate(R.layout.image_text_view,null);
  v.setLayoutParams(new GridView.LayoutParams(200,200));
 }
 else {
  v = convertView;
 }

 ImageView imageview = (ImageView)v.findViewById(R.id.image);
 imageview.setScaleType(ImageView.ScaleType.CENTER_CROP);
 imageview.setPadding(6, 6, 6, 6);
 imageDownloader.download(URLS[position], imageview);

 return v;
}

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

public View getView(int position, View convertView, ViewGroup parent) {
   ImageView imageView;
   if (convertView == null) {  // if it's not recycled, initialize some attributes
     imageView = new ImageView(mContext);
     imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
     imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
     imageView.setPadding(8, 8, 8, 8);
   } else {
     imageView = (ImageView) convertView;
   }
   imageView.setImageResource(mThumbIds[position]);
   return imageView;
 }

代码示例来源:origin: SiberiaDante/TitleLayout

private void settingRightImage() {
  if (mRightImage != 0) {
    mIvRight.setVisibility(VISIBLE);
    mTvRight.setVisibility(GONE);
    mIvRight.setImageResource(mRightImage);
    ViewGroup.LayoutParams mIvRightLayoutParams = mIvRight.getLayoutParams();
    mIvRightLayoutParams.width = mRightImageWidth + mRightImagePaddingEnd + mRightImagePaddingStart;
    mIvRight.setLayoutParams(mIvRightLayoutParams);
    mIvRight.setPadding(mRightImagePaddingStart, 0, mRightImagePaddingEnd, 0);
  } else {
    mIvRight.setVisibility(GONE);
  }
}

相关文章

ImageView类方法