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

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

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

ImageView.setBackgroundDrawable介绍

暂无

代码示例

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

ImageView myIcon;
//...
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MyLayout);
Drawable drawable = a.getDrawable(R.styleable.MyLayout_icon);
if (drawable != null)
  myIcon.setBackgroundDrawable(drawable);

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

public void setDrawableIcon(Drawable drawableIcon) {
  this.drawableIcon = drawableIcon;
  try {
    icon.setBackground(drawableIcon);
  } catch (NoSuchMethodError e) {
    icon.setBackgroundDrawable(drawableIcon);
  }
}

代码示例来源:origin: vinc3m1/RoundedImageView

@Override
@Deprecated
public void setBackgroundDrawable(Drawable background) {
 mBackgroundDrawable = background;
 updateBackgroundDrawableAttrs(true);
 //noinspection deprecation
 super.setBackgroundDrawable(mBackgroundDrawable);
}

代码示例来源:origin: aa112901/remusic

@Override
public void setBackgroundDrawable(Drawable background) {
  super.setBackgroundDrawable(background);
  if (mBackgroundHelper != null) {
    mBackgroundHelper.setBackgroundDrawableExternal(background);
  }
}

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

BitmapDrawable TileMe = new BitmapDrawable(MyBitmap);
TileMe.setTileModeX(Shader.TileMode.REPEAT);
TileMe.setTileModeY(Shader.TileMode.REPEAT);
ImageView Item = new ImageView(this);
Item.setBackgroundDrawable(TileMe);

代码示例来源:origin: Aspsine/SwipeToLoadLayout

@Override
protected void onFinishInflate() {
  super.onFinishInflate();
  ivRefresh = (ImageView) findViewById(R.id.ivRefresh);
  ivRefresh.setBackgroundDrawable(ringProgressDrawable);
}

代码示例来源:origin: JackyAndroid/AndroidTVLauncher

@Override
public View getView(int position, View convertView, ViewGroup parent) {
  Holder holder;
  if (convertView == null) {
    holder = new Holder();
    convertView = LayoutInflater.from(context).inflate(
        R.layout.item_app_uninstall, null);
    holder.name = (TextView) convertView
        .findViewById(R.id.item_app_uninstall_name);
    holder.icon = (ImageView) convertView
        .findViewById(R.id.item_app_uninstall_iv);
    convertView.setTag(holder);
  } else {
    holder = (Holder) convertView.getTag();
  }
  AppModel appBean = appBeanList.get(position);
  holder.icon.setBackgroundDrawable(appBean.getIcon());
  holder.name.setText(appBean.getName());
  return convertView;
}

代码示例来源:origin: Aspsine/SwipeToLoadLayout

@Override
protected void onFinishInflate() {
  super.onFinishInflate();
  ivLoadMore = (ImageView) findViewById(R.id.ivLoadMore);
  ivLoadMore.setBackgroundDrawable(ringProgressDrawable);
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

splashImageView.setBackgroundDrawable(drawable);
} else {
  splashImageView.setImageResource(splashPicID);

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

splashImageView.setBackgroundDrawable(drawable);
} else {
  splashImageView.setImageResource(splashPicID);

代码示例来源:origin: ZieIony/Carbon

@Override
public void setBackgroundDrawable(Drawable background) {
  if (background instanceof RippleDrawable) {
    setRippleDrawable((RippleDrawable) background);
    return;
  }
  if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Background) {
    rippleDrawable.setCallback(null);
    rippleDrawable = null;
  }
  super.setBackgroundDrawable(background);
  updateBackgroundTint();
}

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

AnimationDrawable animation = new AnimationDrawable();
 animation.addFrame(getResources().getDrawable(R.drawable.image1), 100);
 animation.addFrame(getResources().getDrawable(R.drawable.image2), 500);
 animation.addFrame(getResources().getDrawable(R.drawable.image3), 300);
 animation.setOneShot(false);
 ImageView imageAnim =  (ImageView) findViewById(R.id.img);
 imageAnim.setBackgroundDrawable(animation);
 // start the animation!
 animation.start()

代码示例来源:origin: vinc3m1/RoundedImageView

super.setBackgroundDrawable(mBackgroundDrawable);

代码示例来源:origin: akexorcist/Android-RoundCornerProgressBar

@SuppressWarnings("deprecation")
private void drawIconBackgroundColor() {
  GradientDrawable iconBackgroundDrawable = createGradientDrawable(colorIconBackground);
  int radius = getRadius() - (getPadding() / 2);
  iconBackgroundDrawable.setCornerRadii(new float[]{radius, radius, 0, 0, 0, 0, radius, radius});
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    ivProgressIcon.setBackground(iconBackgroundDrawable);
  } else {
    ivProgressIcon.setBackgroundDrawable(iconBackgroundDrawable);
  }
}

代码示例来源:origin: Aspsine/SwipeToLoadLayout

@Override
protected void onFinishInflate() {
  super.onFinishInflate();
  ivRefresh = (ImageView) findViewById(R.id.ivRefresh);
  mDrawable = new SunRefreshDrawable(getContext(), this, mTriggerOffset, DensityUtil.getScreenWidth(getContext()));
  ivRefresh.setBackgroundDrawable(mDrawable);
}

代码示例来源:origin: ZieIony/Carbon

@Override
public void setRippleDrawable(RippleDrawable newRipple) {
  if (rippleDrawable != null) {
    rippleDrawable.setCallback(null);
    if (rippleDrawable.getStyle() == RippleDrawable.Style.Background)
      super.setBackgroundDrawable(rippleDrawable.getBackground());
  }
  if (newRipple != null) {
    newRipple.setCallback(this);
    newRipple.setBounds(0, 0, getWidth(), getHeight());
    newRipple.setState(getDrawableState());
    ((Drawable) newRipple).setVisible(getVisibility() == VISIBLE, false);
    if (newRipple.getStyle() == RippleDrawable.Style.Background)
      super.setBackgroundDrawable((Drawable) newRipple);
  }
  rippleDrawable = newRipple;
}

代码示例来源:origin: ImmortalZ/TransitionHelper

ivTemp.setImageDrawable(new BitmapDrawable(bean.bitmap));
} else {
  ivTemp.setBackgroundDrawable(new BitmapDrawable(bean.bitmap));

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

final ImageView imageView = new ImageView(context);
imageView.setPadding(2*border,2*border,0,0);
final ViewGroup.MarginLayoutParams params = new ViewGroup.MarginLayoutParams(width,height);
params.leftMargin = marginYouWouldSet + border;
params.topMargin = marginYouWouldSet + border;
imageView.setBackgroundDrawable(drawable);
imageView.setBackgroundColor(borderColor);
addView(imageView, params);

代码示例来源:origin: dongjunkun/GanK

@Override
protected void onFinishInflate() {
  super.onFinishInflate();
  ivRefresh = (ImageView) findViewById(R.id.ivRefresh);
  ivRefresh.setBackgroundDrawable(ringProgressDrawable);
}

代码示例来源:origin: sunfusheng/GlideImageView

private void setBackground() {
  if (radius == 0) {
    getView().setBackgroundResource(R.drawable.drawable_image_bg_0dp);
  } else if (radius == 5) {
    getView().setBackgroundResource(R.drawable.drawable_image_bg_5dp);
  } else {
    GradientDrawable drawable = (GradientDrawable) getResources().getDrawable(R.drawable.drawable_image_bg_0dp);
    drawable.setCornerRadius(radius);
    getView().setBackgroundDrawable(drawable);
  }
}

相关文章

ImageView类方法