Java Code Examples for android.widget.ImageView#setBackgroundColor()

The following examples show how to use android.widget.ImageView#setBackgroundColor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PwaWrapperSplashScreenStrategy.java    From android-browser-helper with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 2
Source File: DribbbleDataAdapter.java    From FreeFlow with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 3
Source File: PicViewer.java    From BigApp_Discuz_Android with Apache License 2.0 6 votes vote down vote up
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);

}
 
Example 4
Source File: CityImageSliderAdapter.java    From Travel-Mate with MIT License 6 votes vote down vote up
@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;
}
 
Example 5
Source File: MainActivity.java    From astrobee_android with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 6
Source File: DribbbleDataAdapter.java    From UltimateAndroid with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 7
Source File: AvatarWorkerTask.java    From Conversations with GNU General Public License v3.0 6 votes vote down vote up
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) {
            }
        }
    }
}
 
Example 8
Source File: EmojiPalettesView.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 9
Source File: ImageLoader.java    From MicroReader with MIT License 5 votes vote down vote up
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);
}
 
Example 10
Source File: AvatarWorkerTask.java    From Pix-Art-Messenger with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void onPostExecute(Bitmap bitmap) {
    if (bitmap != null && !isCancelled()) {
        final ImageView imageView = imageViewReference.get();
        if (imageView != null) {
            imageView.setImageBitmap(bitmap);
            imageView.setBackgroundColor(0x00000000);
        }
    }
}
 
Example 11
Source File: PhotoPickerActivity.java    From Yahala-Messenger with MIT License 5 votes vote down vote up
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);
    }
}
 
Example 12
Source File: SwipeBackDelegate.java    From Readhub with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 13
Source File: AbsBaseSwipeBackActivity.java    From LLApp with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 14
Source File: PicViewer.java    From Huochexing12306 with Apache License 2.0 5 votes vote down vote up
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);
	}
}
 
Example 15
Source File: EmojiPalettesView.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 16
Source File: QrDisplayActivity.java    From zom-android-matrix with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 17
Source File: Numpad.java    From Numpad with Apache License 2.0 4 votes vote down vote up
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);
        }
    }
 
Example 18
Source File: MediaAdapter.java    From Conversations with GNU General Public License v3.0 4 votes vote down vote up
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)));
}
 
Example 19
Source File: TubiExoPlayerView.java    From TubiPlayer with MIT License 4 votes vote down vote up
@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));
}
 
Example 20
Source File: TubiExoPlayerView.java    From TubiPlayer with MIT License 4 votes vote down vote up
@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));
}