本文整理汇总了Java中android.widget.ImageView.setBackgroundColor方法的典型用法代码示例。如果您正苦于以下问题:Java ImageView.setBackgroundColor方法的具体用法?Java ImageView.setBackgroundColor怎么用?Java ImageView.setBackgroundColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ImageView
的用法示例。
在下文中一共展示了ImageView.setBackgroundColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mRed = new SeekText(R.id.seek_red, R.id.txt_red, 255);
mGreen = new SeekText(R.id.seek_green, R.id.txt_green, 255);
mBlue = new SeekText(R.id.seek_blue, R.id.txt_blue, 255);
mImageView = (ImageView) findViewById(R.id.img_preview);
mImageView.setBackgroundColor(Color.argb(0, 255, 255, 255));
mUsbManager = (UsbManager) getSystemService(USB_SERVICE);
mPermIntent = PendingIntent.getBroadcast(this, 0, new Intent(ACTION_USB_PERMISSION), 0);
mUsbThread = new HandlerThread("USB Handler");
mUsbThread.start();
mUsbHandler = new Handler(mUsbThread.getLooper());
mMainHandler = new Handler();
}
示例2: addDotView
import android.widget.ImageView; //导入方法依赖的package包/类
/**
* 周视图上面的小点
*
* @param hour
* @param j
*/
public void addDotView(int hour, int j) {
if (j == 7 || hour == 10) {
return;
}
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(DensityUtils.dp2px(context, 3),
DensityUtils.dp2px(context, 3));
params.topMargin = hour * gridHeight;
params.leftMargin = aveWidth * j;
ImageView view = new ImageView(context);
view.setLayoutParams(params);
view.setBackgroundColor(getResources().getColor(R.color.week_view_text_date));
if (courseLayout != null) {
courseLayout.addView(view);
}
}
示例3: onCreate
import android.widget.ImageView; //导入方法依赖的package包/类
public void onCreate() {
ivViewer = new ImageView(activity);
ivViewer.setScaleType(ScaleType.CENTER_INSIDE);
ivViewer.setBackgroundColor(0xc0000000);
ivViewer.setOnClickListener(this);
activity.setContentView(ivViewer);
if (pic != null && !pic.isRecycled()) {
ivViewer.setImageBitmap(pic);
}
}
示例4: onCreateView
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ImageView iv = (ImageView) inflater.inflate(R.layout.tutorial_img,
null, false);
iv.setImageBitmap(null);
iv.setBackgroundColor(Color.BLACK);
iv.setImageResource(tutImgs[getArguments().getInt("indx")]);
return iv;
}
示例5: getView
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
public View getView(int i, View view) {
ImageView iv = new ImageView(context);
iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
iv.setBackgroundColor(Color.parseColor("#f5f5f5"));
Picasso.with(context).load(getUrl(i)).placeholder(new ColorDrawable(Color.parseColor("#f5f5f5"))).into(iv);
return iv;
}
示例6: creatImg
import android.widget.ImageView; //导入方法依赖的package包/类
ImageView creatImg(){
ImageView top = new ImageView(getContext());
top.setLayoutParams(new LayoutParams(width,width));
top.setY(height - width);
top.setBackgroundColor(0xFF999999);
top.setScaleType(ImageView.ScaleType.CENTER_CROP);
return top;
}
示例7: loadImage
import android.widget.ImageView; //导入方法依赖的package包/类
public static void loadImage(Context context, String url, ImageView imageView) {
// 夜间模式的处理
if (SPUtil.getBoolean(Constants.IS_NIGHT_MODE)) {
imageView.setAlpha(0.2f);
imageView.setBackgroundColor(Color.BLACK);
}
Glide.with(context).load(url).into(imageView);
}
示例8: initThumbs
import android.widget.ImageView; //导入方法依赖的package包/类
/**
* 初始化缩略图
*/
private void initThumbs(){
final int frame = 15;
final int frameTime = videoDuration/frame*1000;
int thumbnailWidth = ll_thumbnail.getWidth()/frame;
for (int x=0; x<frame; x++){
ImageView imageView = new ImageView(this);
imageView.setLayoutParams(new ViewGroup.LayoutParams(thumbnailWidth, ViewGroup.LayoutParams.MATCH_PARENT));
imageView.setBackgroundColor(Color.parseColor("#666666"));
imageView.setScaleType(ImageView.ScaleType.CENTER);
ll_thumbnail.addView(imageView);
}
new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... params) {
MediaMetadataRetriever mediaMetadata= new MediaMetadataRetriever();
mediaMetadata.setDataSource(mContext, Uri.parse(path));
for (int x=0; x<frame; x++){
Bitmap bitmap = mediaMetadata.getFrameAtTime(frameTime*x, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
Message msg = myHandler.obtainMessage();
msg.obj = bitmap;
msg.arg1 = x;
myHandler.sendMessage(msg);
}
mediaMetadata.release();
return true;
}
@Override
protected void onPostExecute(Boolean result) {
}
}.execute();
}
示例9: songSliderThumb
import android.widget.ImageView; //导入方法依赖的package包/类
public songSliderThumb(Context context, int width, int height,int ID) {
super(context, width, height);
this.ID = ID;
setBackgroundColor(0x0000000);
//SongSliderImg = new songSliderImg(width,height,0,0);
RaidiusSqure = new radiusSqure(width,height,0,0,width*0.1f);
RaidiusSqure.setColor(0xFFFFFFFF);
name = textImg.getFMText(getContext(),"DEMO", Ui.cd.getHt(16));
back = thumbBack.getFMview(getContext(),false);
back.setSize(width - Ui.cd.getHt(2),height - Ui.cd.getHt(2));
back.setX(Ui.cd.getHt(1));
back.setY(Ui.cd.getHt(1));
back.setClickable(false);
addView(back);
Iv = new ImageView(context){
@Override
protected void onDraw(Canvas canvas) {
canvas.clipPath(back.img.mask);
super.onDraw(canvas);
}
};
Iv.setLayoutParams(new FrameLayout.LayoutParams(width - Ui.cd.getHt(2),height - Ui.cd.getHt(2)));
addView(Iv);
Iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
Iv.setBackgroundColor(0x00FFFFFF);
Iv.setX(Ui.cd.getHt(1));
Iv.setY(Ui.cd.getHt(1));
//setImg("3.png");
ring = thumbRing.getFMview(getContext(),false);
ring.setSize(width,height);
ring.setClickable(false);
addView(ring);
if(android.os.Build.VERSION.SDK_INT <= 18){
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
// addView(name);
}
示例10: configureEditModeLogo
import android.widget.ImageView; //导入方法依赖的package包/类
@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));
}
示例11: UploadView
import android.widget.ImageView; //导入方法依赖的package包/类
public UploadView(Context context, String uploadId, Bitmap bm, String title, String statusText, String pText, int progress) {
super(context);
idView = new TextView(context);
idView.setVisibility(View.GONE);
idView.setText(uploadId + "");
imageView = new ImageView(context);
imageView.setImageBitmap(bm);
imageView.setBackgroundColor(0xFF666666);
imageView.setId(VIDEOIMAGE_ID);
titleView = new TextView(context);
titleView.setText(title);
titleView.setTextColor(0xFF000000);
titleView.setId(TITLEVIEW_ID);
titleView.setPaddingRelative(5, 5, 0, 0);
statusTextView = new TextView(context);
statusTextView.setText(statusText);
statusTextView.setTextColor(0xFF000000);
statusTextView.setId(STATUSVIEW_ID);
statusTextView.setPaddingRelative(5, 5, 0, 0);
statusTextView.setTextColor(Color.GRAY);
progressTextView = new TextView(context);
progressTextView.setText(pText);
progressTextView.setTextColor(0xFF000000);
progressTextView.setId(PROGRESSTEXT_ID);
progressTextView.setPaddingRelative(5, 5, 0, 0);
progressTextView.setTextColor(Color.GRAY);
progressBar = new ProgressBar(context, null, android.R.attr.progressBarStyleHorizontal);
progressBar.setMax(100);
progressBar.setIndeterminate(false);
progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar));
progressBar.setId(PROGRESSBAR_ID);
progressBar.setPaddingRelative(5, 0, 0, 0);
progressBar.setProgress(progress);
/**
*
* + + + + title
* + img + 0M / 0M
* + + 下载中
* + + + + ********progress**************
*
* */
//左侧
LayoutParams imageLayoutParams = new LayoutParams(ParamsUtil.dpToPx(context, 75), ParamsUtil.dpToPx(context, 75));
imageLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
//位于图片右侧
LayoutParams titleLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
titleLayoutParams.addRule(RelativeLayout.RIGHT_OF, VIDEOIMAGE_ID);
//位于标题下方
LayoutParams statusLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
statusLayoutParams.addRule(RelativeLayout.BELOW, TITLEVIEW_ID);
statusLayoutParams.addRule(RelativeLayout.RIGHT_OF, VIDEOIMAGE_ID);
//位于状态下方
LayoutParams progressTextParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
progressTextParams.addRule(RelativeLayout.BELOW, STATUSVIEW_ID);
progressTextParams.addRule(RelativeLayout.RIGHT_OF, VIDEOIMAGE_ID);
//位于图片左侧,进度文本下方
LayoutParams progressBarLayoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, ParamsUtil.dpToPx(context, 7));
progressBarLayoutParams.addRule(RelativeLayout.RIGHT_OF, VIDEOIMAGE_ID);
progressBarLayoutParams.addRule(RelativeLayout.BELOW, PROGRESSTEXT_ID);
progressBarLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
addView(imageView, imageLayoutParams);
addView(titleView, titleLayoutParams);
addView(statusTextView, statusLayoutParams);
addView(progressTextView, progressTextParams);
addView(progressBar, progressBarLayoutParams);
setPadding(5, 5, 5, 5);
}
示例12: onCreate
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Random random = new Random();
switch (random.nextInt(4))
{
case 0:
setFadeAnimation();
break;
case 1:
setZoomAnimation();
break;
case 2:
setFlowAnimation();
break;
case 3:
setSlideOverAnimation();
break;
case 4:
setDepthAnimation();
break;
}
SliderPage sliderPage1 = new SliderPage();
sliderPage1.setTitle("Welcome!");
sliderPage1.setDescription("This is a demo of the AppIntro library, with a custom background on each slide!");
sliderPage1.setImageDrawable(R.mipmap.ic_launcher);
sliderPage1.setBgColor(Color.TRANSPARENT);
addSlide(AppIntroFragment.newInstance(sliderPage1));
SliderPage sliderPage2 = new SliderPage();
sliderPage2.setTitle("Clean App Intros");
sliderPage2.setDescription("This library offers developers the ability to add clean app intros at the start of their apps.");
sliderPage2.setImageDrawable(R.mipmap.ic_launcher);
sliderPage2.setBgColor(Color.TRANSPARENT);
addSlide(AppIntroFragment.newInstance(sliderPage2));
SliderPage sliderPage3 = new SliderPage();
sliderPage3.setTitle("Simple, yet Customizable");
sliderPage3.setDescription("The library offers a lot of customization, while keeping it simple for those that like simple.");
sliderPage3.setImageDrawable(R.mipmap.ic_launcher);
sliderPage3.setBgColor(Color.TRANSPARENT);
addSlide(AppIntroFragment.newInstance(sliderPage3));
SliderPage sliderPage4 = new SliderPage();
sliderPage4.setTitle("Explore");
sliderPage4.setDescription("Feel free to explore the rest of the library demo!");
sliderPage4.setImageDrawable(R.mipmap.ic_launcher);
sliderPage4.setBgColor(Color.TRANSPARENT);
addSlide(AppIntroFragment.newInstance(sliderPage4));
// Declare a new image view
ImageView imageView = new ImageView(this);
// Bind a drawable to the imageview
// imageView.setImageResource(R.mipmap.ic_launcher);
// Set background color
imageView.setBackgroundColor(Color.GRAY);
// Set layout params
imageView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
// Bind the background to the intro
setBackgroundView(imageView);
}
示例13: onCreate
import android.widget.ImageView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(this.getIntent() != null) {
this._SourceUrl = this.getIntent().getStringExtra(EXTRA_IMAGE_SOURCE);
if(this._SourceUrl != null) {
ImageView _ImageView = new TouchImageView(this);
_ImageView.setBackgroundColor(Color.WHITE);
_ImageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
_ImageView.setAdjustViewBounds(true);
try {
Customerly.get()._RemoteImageHandler.request(new IU_RemoteImageHandler.Request()
.fitCenter()
.load(this._SourceUrl)
.into(this, _ImageView)
.placeholder(R.drawable.io_customerly__pic_placeholder_fullscreen));
super.setContentView(_ImageView);
final ActionBar actionBar = this.getSupportActionBar();
if (actionBar != null) {
String title;
if(Customerly.get().__PING__LAST_widget_color != 0) {
actionBar.setBackgroundDrawable(new ColorDrawable(Customerly.get().__PING__LAST_widget_color));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
this.getWindow().setStatusBarColor(IU_Utils.alterColor(Customerly.get().__PING__LAST_widget_color, 0.8f));
}
if (IU_Utils.getContrastColor(Customerly.get().__PING__LAST_widget_color) == Color.BLACK) {
actionBar.setHomeAsUpIndicator(R.drawable.io_customerly__ic_arrow_back_black_24dp);
title = String.format("<font color='#000000'>%1$s</font>", actionBar.getTitle());
} else {
actionBar.setHomeAsUpIndicator(R.drawable.io_customerly__ic_arrow_back_white_24dp);
title = String.format("<font color='#ffffff'>%1$s</font>", actionBar.getTitle());
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
actionBar.setTitle(Html.fromHtml(title, 0));
} else {
//noinspection deprecation
actionBar.setTitle(Html.fromHtml(title));
}
}
actionBar.setDisplayHomeAsUpEnabled(true);
}
return;
} catch (Exception glideException) {
IEr_CustomerlyErrorHandler.sendError(IEr_CustomerlyErrorHandler.ERROR_CODE__GLIDE_ERROR, "Error during Glide loading in FullScreenImage_Activity", glideException);
}
}
}
this.finish();
}
示例14: initialize
import android.widget.ImageView; //导入方法依赖的package包/类
public void initialize(Context context) {
this.setBackgroundColor(Color.WHITE);
final int width = 90;
final int height = 90;
final int margin = 13;
final int length = PointPath.mPathColors.length;
int left = 10;
for (int i = 0; i < length; ++i) {
int color = PointPath.mPathColors[i];
ImageView imgBtn = new ImageView(context);
if (CURRENT_TYPE == STROCK_TYPE) {
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setStrokeWidth(PointPath.mPenStrock[i]);
canvas.drawLine(0, height, width, 0, paint);
imgBtn.setImageBitmap(bitmap);
imgBtn.setBackgroundColor(Color.WHITE);
} else {
imgBtn.setBackgroundColor(color);
}
imgBtn.setOnClickListener(m_clickListener);
imgBtn.setTag(i);
LayoutParams params = new LayoutParams(width, height);
params.setMargins(left, 30, 0, 0);
params.addRule(Gravity.CENTER_VERTICAL);
left += (margin + width);
this.addView(imgBtn, params);
}
// Cancel button.
Button btnCancel = new Button(context);
btnCancel.setText("cancel");
btnCancel.setId(CANCEL_BUTTON_ID);
btnCancel.setTextSize(8);
btnCancel.setOnClickListener(m_clickListener);
LayoutParams btnCancelparams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, height);
btnCancelparams.addRule(Gravity.CENTER);
left += 10;
btnCancelparams.setMargins(left, 30, 0, 0);
this.addView(btnCancel, btnCancelparams);
}
示例15: configureEditModeLogoV23
import android.widget.ImageView; //导入方法依赖的package包/类
@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));
}