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

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

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

ImageView.setBackgroundColor介绍

暂无

代码示例

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

RelativeLayout rl = (RelativeLayout) findViewById(R.id.my_relative_layout);
ImageView iv;
RelativeLayout.LayoutParams params;

iv = new ImageView(this);
iv.setBackgroundColor(Color.YELLOW);
params = new RelativeLayout.LayoutParams(30, 40);
params.leftMargin = 50;
params.topMargin = 60;
rl.addView(iv, params);

iv = new ImageView(this);
iv.setBackgroundColor(Color.RED);
params = new RelativeLayout.LayoutParams(30, 40);
params.leftMargin = 80;
params.topMargin = 90;
rl.addView(iv, params);

代码示例来源:origin: google/ExoPlayer

@TargetApi(23)
private static void configureEditModeLogoV23(Resources resources, ImageView logo) {
 logo.setImageDrawable(resources.getDrawable(R.drawable.exo_edit_mode_logo, null));
 logo.setBackgroundColor(resources.getColor(R.color.exo_edit_mode_background_color, null));
}

代码示例来源:origin: google/ExoPlayer

@SuppressWarnings("deprecation")
private static void configureEditModeLogo(Resources resources, ImageView logo) {
 logo.setImageDrawable(resources.getDrawable(R.drawable.exo_edit_mode_logo));
 logo.setBackgroundColor(resources.getColor(R.color.exo_edit_mode_background_color));
}

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

RelativeLayout rl = (RelativeLayout) findViewById(R.id.my_relative_layout);
ImageView iv;
RelativeLayout.LayoutParams params;

int yellow_iv_id = 123; // Some arbitrary ID value.

iv = new ImageView(this);
iv.setId(yellow_iv_id);
iv.setBackgroundColor(Color.YELLOW);
params = new RelativeLayout.LayoutParams(30, 40);
params.leftMargin = 50;
params.topMargin = 60;
rl.addView(iv, params);

iv = new ImageView(this);
iv.setBackgroundColor(Color.RED);
params = new RelativeLayout.LayoutParams(30, 40);
params.leftMargin = 80;
params.topMargin = 90;

// This line defines how params.leftMargin and params.topMargin are interpreted.
// In this case, "<80,90>" means <80,90> to the right of the yellow ImageView.
params.addRule(RelativeLayout.RIGHT_OF, yellow_iv_id);

rl.addView(iv, params);

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

@Override
public void setBackgroundColor(int color) {
  super.setBackgroundColor(color);
  if (mBackgroundHelper != null) {
    mBackgroundHelper.setBackgroundColor(color);
  }
}

代码示例来源:origin: Ramotion/folding-cell-android

/**
 * Create image view for display back side of flip view
 *
 * @param height height for view
 * @return ImageView with selected height and default background color
 */
protected ImageView createBackSideView(int height) {
  ImageView imageView = new ImageView(getContext());
  imageView.setBackgroundColor(mBackSideColor);
  imageView.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, height));
  return imageView;
}

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

public void refreshCover(Bitmap bitmap) {
  if (pauseSwitchCoverBitmap != null) {
    JCVideoPlayerStandard jcVideoPlayerStandard = ((JCVideoPlayerStandard) JCVideoPlayerManager.listener());
    jcVideoPlayerStandard.coverImageView.setBackgroundColor(Color.parseColor("#000000"));
    jcVideoPlayerStandard.coverImageView.setImageBitmap(bitmap);
    jcVideoPlayerStandard.coverImageView.setVisibility(VISIBLE);
  }
}

代码示例来源:origin: nanchen2251/CompressHelper

private void clearImage() {
  mImageOld.setBackgroundColor(getRandomColor());
  mImageNew.setImageDrawable(null);
  mImageNew.setBackgroundColor(getRandomColor());
  mTextNew.setText("Size : -");
}

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

//...
FrameLayout root = (FrameLayout)findViewById(R.id.root);
ImageView img = new ImageView(this);
img.setBackgroundColor(Color.RED);
//..load something inside the ImageView, we just set the background color

FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(20, 20);
params.leftMargin = 100;
params.topMargin  = 200;
root.addView(img, params);
//...

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

@Override
public void prepareVideo() {
  coverImageView.setBackgroundColor(Color.parseColor("#222222"));
  coverImageView.setImageBitmap(null);
  super.prepareVideo();
}

代码示例来源:origin: nanchen2251/AiYaCompressHelper

private void clearImage() {
  mImageOld.setBackgroundColor(getRandomColor());
  mImageNew.setImageDrawable(null);
  mImageNew.setBackgroundColor(getRandomColor());
  mTextNew.setText("Size : -");
}

代码示例来源:origin: 4thline/cling

public void run() {
    ImageView imageView = (ImageView) findViewById(R.id.light_imageview);
    imageView.setImageResource(on ? R.drawable.light_on : R.drawable.light_off);
    // You can NOT externalize this color into /res/values/colors.xml. Go on, try it!
    imageView.setBackgroundColor(on ? Color.parseColor("#9EC942") : Color.WHITE);
  }
});

代码示例来源:origin: janishar/PlaceHolderView

@SwipeHead
public void onSwipeHead() {
  profileImageView.setBackgroundColor(Color.BLUE);
  Log.d("DEBUG", "onSwipeHead");
}

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

// create a new ImageView for each item referenced by the Adapter
 public View getView(int position, View convertView, ViewGroup parent) {
   ImageView imageView;
   if (convertView == null) {  
     //Calculation of ImageView Size - density independent.
     //maybe you should do this calculation not exactly in this method but put is somewhere else.
     Resources r = Resources.getSystem();
     float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 60, r.getDisplayMetrics());
     imageView = new ImageView(mContext);
     imageView.setLayoutParams(new GridView.LayoutParams((int)px, (int)px));
     imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
     //imageView.setPadding(8, 8, 8, 8);
     imageView.setBackgroundColor(Color.BLUE);
   } else {
     imageView = (ImageView) convertView;
   }
   imageView.setImageResource(mThumbIds[position]);
   return imageView;
 }

代码示例来源:origin: xinghongfei/LookLook

public static void loadImage(Context context, String url, ImageView imageView) {
    if (Config.isNight) {
      imageView.setAlpha(0.2f);
      imageView.setBackgroundColor(Color.BLACK);
    }
    Glide.with(context).load(url).centerCrop().into(imageView);
  }
}

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

@Override
public boolean setUp(String url, int screen, Object... objects) {
  if (objects.length == 0) return false;
  if (super.setUp(url, screen, objects)) {
    if (pauseSwitchCoverBitmap != null && coverImageView.getBackground() == null) {
      coverImageView.setBackgroundColor(Color.parseColor("#222222"));//防止在复用的时候导致,闪一下上次暂停切换缓存的图的问题
    }
    titleTextView.setText(objects[0].toString());
    if (currentScreen == SCREEN_WINDOW_FULLSCREEN) {
      fullscreenButton.setImageResource(R.drawable.jc_shrink);
      backButton.setVisibility(View.VISIBLE);
      tinyBackImageView.setVisibility(View.INVISIBLE);
    } else if (currentScreen == SCREEN_LAYOUT_LIST) {
      fullscreenButton.setImageResource(R.drawable.jc_enlarge);
      backButton.setVisibility(View.GONE);
      tinyBackImageView.setVisibility(View.INVISIBLE);
    } else if (currentScreen == SCREEN_WINDOW_TINY) {
      tinyBackImageView.setVisibility(View.VISIBLE);
      setAllControlsVisible(View.INVISIBLE, View.INVISIBLE, View.INVISIBLE,
          View.INVISIBLE, View.INVISIBLE, View.INVISIBLE, View.INVISIBLE);
    }
    return true;
  }
  return false;
}

代码示例来源:origin: liuguangqiang/SwipeBack

private View getContainer() {
  RelativeLayout container = new RelativeLayout(this);
  swipeBackLayout = new SwipeBackLayout(this);
  swipeBackLayout.setDragEdge(DEFAULT_DRAG_EDGE);
  swipeBackLayout.setOnSwipeBackListener(this);
  ivShadow = new ImageView(this);
  ivShadow.setBackgroundColor(getResources().getColor(R.color.black_p50));
  LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
  container.addView(ivShadow, params);
  container.addView(swipeBackLayout);
  return container;
}

代码示例来源:origin: jeasonlzy/ImagePicker

@Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ImageView imageView;
    int size = gridView.getWidth() / 3;
    if (convertView == null) {
      imageView = new ImageView(ImagePickerActivity.this);
      AbsListView.LayoutParams params = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, size);
      imageView.setLayoutParams(params);
      imageView.setBackgroundColor(Color.parseColor("#88888888"));
    } else {
      imageView = (ImageView) convertView;
    }
    imagePicker.getImageLoader().displayImage(ImagePickerActivity.this, getItem(position).path, imageView, size, size);
    return imageView;
  }
}

代码示例来源:origin: ybq/Android-SpinKit

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);
  //ProgressBar
  ProgressBar progressBar = (ProgressBar) view.findViewById(R.id.progress);
  DoubleBounce doubleBounce = new DoubleBounce();
  doubleBounce.setBounds(0, 0, 100, 100);
  doubleBounce.setColor(colors[7]);
  progressBar.setIndeterminateDrawable(doubleBounce);
  //Button
  Button button = (Button) view.findViewById(R.id.button);
  mWaveDrawable = new Wave();
  mWaveDrawable.setBounds(0, 0, 100, 100);
  //noinspection deprecation
  mWaveDrawable.setColor(getResources().getColor(R.color.colorAccent));
  button.setCompoundDrawables(mWaveDrawable, null, null, null);
  //TextView
  TextView textView = (TextView) view.findViewById(R.id.text);
  mCircleDrawable = new Circle();
  mCircleDrawable.setBounds(0, 0, 100, 100);
  mCircleDrawable.setColor(Color.WHITE);
  textView.setCompoundDrawables(null, null, mCircleDrawable, null);
  textView.setBackgroundColor(colors[2]);
  //ImageView
  ImageView imageView = (ImageView) view.findViewById(R.id.image);
  mChasingDotsDrawable = new ChasingDots();
  mChasingDotsDrawable.setColor(Color.WHITE);
  imageView.setImageDrawable(mChasingDotsDrawable);
  imageView.setBackgroundColor(colors[0]);
}

代码示例来源:origin: AppIntro/AppIntro

imageView.setBackgroundColor(Color.BLACK);

相关文章

ImageView类方法