下面列出了android.widget.ImageView#setBackgroundColor ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Splash screen is shown both before the Trusted Web Activity is launched - in this activity,
* and for some time after that - in browser, on top of web page being loaded.
* This method shows the splash screen in the LauncherActivity.
*/
private void showSplashScreen() {
mSplashImage = Utils.convertDrawableToBitmap(mActivity, mDrawableId);
if (mSplashImage == null) {
Log.w(TAG, "Failed to retrieve splash image from provided drawable id");
return;
}
ImageView view = new ImageView(mActivity);
view.setLayoutParams(new ViewGroup.LayoutParams(MATCH_PARENT, MATCH_PARENT));
view.setImageBitmap(mSplashImage);
view.setBackgroundColor(mBackgroundColor);
view.setScaleType(mScaleType);
if (mScaleType == ImageView.ScaleType.MATRIX) {
view.setImageMatrix(mTransformationMatrix);
}
mActivity.setContentView(view);
}
@Override
public View getItemView(int sectionIndex, int position, View convertView,
ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(
R.layout.pic_view, parent, false);
}
ImageView img = (ImageView) convertView.findViewById(R.id.pic);
if (hideImages) {
int idx = position % colors.length;
img.setBackgroundColor(colors[idx]);
} else {
Shot s = (Shot)(this.section.getData().get(position));
Picasso.with(context)
.load(s.getImage_teaser_url())
.into(img);
}
return convertView;
}
public void onCreate() {
ivViewer = new ImageView(activity);
ivViewer.setScaleType(ScaleType.MATRIX);
ivViewer.setBackgroundColor(0xc0000000);
ivViewer.setOnTouchListener(this);
if (pic != null && !pic.isRecycled()) {
ivViewer.setImageBitmap(pic);
}
dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);// 获取分辨率
minZoom();
CheckView();
ivViewer.setImageMatrix(matrix);
activity.setContentView(ivViewer);
}
@NonNull
@Override
public Object instantiateItem(@NonNull ViewGroup container, int position) {
ImageView imageView = new ImageView(mContext);
//display default city image if no image is present in array
if (mImagesArray.size() == 0) {
Picasso.with(mContext).load(R.drawable.placeholder_image)
.error(R.drawable.placeholder_image).fit().centerCrop().into(imageView);
}
Picasso.with(mContext).load(mImagesArray.get(position))
.error(R.drawable.placeholder_image).fit().centerCrop().into(imageView);
container.addView(imageView);
imageView.setOnClickListener(v -> {
Intent fullScreenIntent = FullScreenImage.getStartIntent(mContext,
mImagesArray.get(position), mCityName);
mContext.startActivity(fullScreenIntent);
});
imageView.setBackgroundColor(Color.TRANSPARENT);
imageView.setAlpha(0.6f);
return imageView;
}
public static void loadAvatar(final AvatarService.Avatarable avatarable, final ImageView imageView, final @DimenRes int size) {
if (cancelPotentialWork(avatarable, imageView)) {
final XmppActivity activity = XmppActivity.find(imageView);
if (activity == null) {
return;
}
final Bitmap bm = activity.avatarService().get(avatarable, (int) activity.getResources().getDimension(size), true);
if (bm != null) {
cancelPotentialWork(avatarable, imageView);
imageView.setImageBitmap(bm);
imageView.setBackgroundColor(0x00000000);
} else {
imageView.setBackgroundColor(avatarable.getAvatarBackgroundColor());
imageView.setImageDrawable(null);
final AvatarWorkerTask task = new AvatarWorkerTask(imageView, size);
final AsyncDrawable asyncDrawable = new AsyncDrawable(activity.getResources(), null, task);
imageView.setImageDrawable(asyncDrawable);
try {
task.execute(avatarable);
} catch (final RejectedExecutionException ignored) {
}
}
}
}
@Override
public View getItemView(int sectionIndex, int position, View convertView,
ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(
R.layout.free_flow_artbook_pic_view, parent, false);
}
ImageView img = (ImageView) convertView.findViewById(R.id.pic);
if (hideImages) {
int idx = position % colors.length;
img.setBackgroundColor(colors[idx]);
} else {
Shot s = (Shot)(this.section.getData().get(position));
Picasso.with(context)
.load(s.getImage_teaser_url())
.into(img);
}
return convertView;
}
@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();
}
private void addTab(final TabHost host, final int categoryId) {
final String tabId = EmojiCategory.getCategoryName(categoryId, 0 /* categoryPageId */);
final TabHost.TabSpec tspec = host.newTabSpec(tabId);
tspec.setContent(R.id.emoji_keyboard_dummy);
final ImageView iconView = (ImageView)LayoutInflater.from(getContext()).inflate(
R.layout.emoji_keyboard_tab_icon, null);
// TODO: Replace background color with its own setting rather than using the
// category page indicator background as a workaround.
iconView.setBackgroundColor(mCategoryPageIndicatorBackground);
iconView.setImageResource(mEmojiCategory.getCategoryTabIcon(categoryId));
iconView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId));
tspec.setIndicator(iconView);
host.addTab(tspec);
}
@Override
protected void onCreate(Bundle state) {
super.onCreate(state);
setRequestedOrientation(SCREEN_ORIENTATION_NOSENSOR);
getSupportActionBar().hide();
String qrData = getIntent().getStringExtra(Intent.EXTRA_TEXT);
ImageView qrCodeView = new ImageView(this);
qrCodeView.setScaleType(FIT_CENTER);
qrCodeView.setBackgroundColor(WHITE);
qrCodeView.setLayoutParams(new LayoutParams(MATCH_PARENT,
MATCH_PARENT, 1f));
Display display = getWindowManager().getDefaultDisplay();
boolean portrait = display.getWidth() < display.getHeight();
layoutMain = new LinearLayout(this);
if(portrait) layoutMain.setOrientation(VERTICAL);
else layoutMain.setOrientation(HORIZONTAL);
layoutMain.setWeightSum(1);
layoutMain.addView(qrCodeView);
setContentView(layoutMain);
new QrGenAsyncTask(this, qrCodeView, 240).executeOnExecutor(ImApp.sThreadPoolExecutor,qrData);
}
private void addTab(final TabHost host, final int categoryId) {
final String tabId = EmojiCategory.getCategoryName(categoryId, 0 /* categoryPageId */);
final TabHost.TabSpec tspec = host.newTabSpec(tabId);
tspec.setContent(R.id.emoji_keyboard_dummy);
final ImageView iconView = (ImageView)LayoutInflater.from(getContext()).inflate(
R.layout.emoji_keyboard_tab_icon, null);
// TODO: Replace background color with its own setting rather than using the
// category page indicator background as a workaround.
iconView.setBackgroundColor(mCategoryPageIndicatorBackground);
iconView.setImageResource(mEmojiCategory.getCategoryTabIcon(categoryId));
iconView.setContentDescription(mEmojiCategory.getAccessibilityDescription(categoryId));
tspec.setIndicator(iconView);
host.addTab(tspec);
}
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);
}
}
private View getContainer() {
RelativeLayout container = new RelativeLayout(this);
swipeBackLayout = new SwipeBackLayout(this);
swipeBackLayout.setOnSwipeBackListener(this);
ivShadow = new ImageView(this);
ivShadow.setBackgroundColor(getResources().getColor(R.color.abc_theme_black_7f));
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
container.addView(ivShadow, params);
container.addView(swipeBackLayout);
return container;
}
@SuppressWarnings("deprecation")
private View getContainer(Context context) {
RelativeLayout container = new RelativeLayout(context);
swipeBackLayout = new SwipeBackLayout(context);
swipeBackLayout.setOnSwipeBackListener(this);
shadow = new ImageView(context);
shadow.setBackgroundColor(context.getResources().getColor(R.color.black_p50));
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RelativeLayout.LayoutParams.MATCH_PARENT);
container.addView(shadow, params);
container.addView(swipeBackLayout);
return container;
}
private void updateSelectedPhoto(View view, MediaController.PhotoEntry photoEntry) {
View frameView = view.findViewById(R.id.photo_frame);
ImageView checkImageView = (ImageView) view.findViewById(R.id.photo_check);
if (selectedPhotos.containsKey(photoEntry.imageId)) {
frameView.setBackgroundResource(R.drawable.photoborder);
checkImageView.setImageResource(R.drawable.selectphoto_small_active);
checkImageView.setBackgroundColor(0xff42d1f6);
} else {
frameView.setBackgroundDrawable(null);
checkImageView.setImageResource(R.drawable.selectphoto_small);
checkImageView.setBackgroundColor(0x501c1c1c);
}
}
@Override
protected void onPostExecute(Bitmap bitmap) {
if (bitmap != null && !isCancelled()) {
final ImageView imageView = imageViewReference.get();
if (imageView != null) {
imageView.setImageBitmap(bitmap);
imageView.setBackgroundColor(0x00000000);
}
}
}
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).into(imageView);
}
private void setup() {
for (TextView textView : num) {
textView.setOnClickListener(this);
textView.setTextSize(TextSize);
textView.setTextColor(TextColor);
textView.setBackgroundResource(BackgroundResource);
textView.setTypeface(typeface);
}
if (GridVisible) {
for (ImageView imageView : line) {
imageView.setVisibility(VISIBLE);
imageView.setBackgroundColor(GridBackgroundColor);
}
line.get(0).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, GridThickness));
line.get(1).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, GridThickness));
line.get(2).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, GridThickness));
line.get(3).setLayoutParams(new LinearLayout.LayoutParams(GridThickness, LayoutParams.MATCH_PARENT));
line.get(4).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, GridThickness));
line.get(5).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, GridThickness));
line.get(6).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, GridThickness));
line.get(7).setLayoutParams(new LinearLayout.LayoutParams(GridThickness, LayoutParams.MATCH_PARENT));
line.get(8).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, GridThickness));
line.get(9).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, GridThickness));
line.get(10).setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, GridThickness));
}
delete_layout.setOnClickListener(this);
delete_layout.setBackgroundResource(BackgroundResource);
delete.setImageResource(ImageResource);
if (CommaString != null) {
comma.setText(CommaString);
comma.setOnClickListener(this);
comma.setTextSize(TextSize);
comma.setTextColor(TextColor);
comma.setBackgroundResource(BackgroundResource);
comma.setTypeface(typeface);
}
}
static void renderPreview(Context context, Attachment attachment, ImageView imageView) {
imageView.setBackgroundColor(StyledAttributes.getColor(context, R.attr.color_background_tertiary));
imageView.setImageAlpha(Math.round(StyledAttributes.getFloat(context, R.attr.icon_alpha) * 255));
imageView.setImageDrawable(StyledAttributes.getDrawable(context, getImageAttr(attachment)));
}
@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));
}
@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));
}