List of usage examples for android.widget ImageView setBackgroundColor
@RemotableViewMethod public void setBackgroundColor(@ColorInt int color)
From source file:com.filemanager.free.adapters.DrawerAdapter.java
@Override public View getView(final int position, View convertView, ViewGroup parent) { if (values.get(position).isSection()) { ImageView view = new ImageView(context); if (m.theme1 == 0) view.setImageResource(R.color.divider); else//from w ww . j a va 2 s .com view.setImageResource(R.color.divider_dark); view.setClickable(false); view.setFocusable(false); if (m.theme1 == 0) view.setBackgroundColor(Color.WHITE); else view.setBackgroundResource(R.color.background_material_dark); view.setLayoutParams(new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, m.dpToPx(17))); view.setPadding(0, m.dpToPx(8), 0, m.dpToPx(8)); return view; } else { View view = inflater.inflate(R.layout.drawerrow, parent, false); final TextView txtTitle = (TextView) view.findViewById(R.id.firstline); final ImageView imageView = (ImageView) view.findViewById(R.id.icon); if (m.theme1 == 0) { view.setBackgroundResource(R.drawable.safr_ripple_white); } else { view.setBackgroundResource(R.drawable.safr_ripple_black); } view.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { m.selectItem(position); } // TODO: Implement this method }); view.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (!getItem(position).isSection()) // not to remove the first bookmark (storage) and permanent bookmarks if (position > m.storage_count && position < values.size() - 7) { EntryItem item = (EntryItem) getItem(position); String path = (item).getPath(); if (DataUtils.containsBooks(new String[] { item.getTitle(), path }) != -1) { m.renameBookmark((item).getTitle(), path); } else if (path.startsWith("smb:/")) { m.showSMBDialog(item.getTitle(), path, true); } } else if (position < m.storage_count) { String path = ((EntryItem) getItem(position)).getPath(); if (!path.equals("/")) new Futils().showProps(RootHelper.generateBaseFile(new File(path), true), m, m.theme1); } // return true to denote no further processing return true; } }); txtTitle.setText(((EntryItem) (values.get(position))).getTitle()); imageView.setImageDrawable(getDrawable(position)); imageView.clearColorFilter(); if (myChecked.get(position)) { if (m.theme1 == 0) view.setBackgroundColor(Color.parseColor("#ffeeeeee")); else view.setBackgroundColor(Color.parseColor("#ff424242")); imageView.setColorFilter(fabskin); txtTitle.setTextColor(Color.parseColor(m.fabskin)); } else { if (m.theme1 == 0) { imageView.setColorFilter(Color.parseColor("#666666")); txtTitle.setTextColor(ContextCompat.getColor(getContext(), android.R.color.black)); } else { imageView.setColorFilter(Color.WHITE); txtTitle.setTextColor(ContextCompat.getColor(getContext(), android.R.color.white)); } } return view; } }
From source file:org.catrobat.catroid.ui.fragment.AddBrickFragment.java
public ImageView getGlowingBorder(Bitmap bitmap) { ImageView imageView = new ImageView(getActivity()); imageView.setBackgroundColor(Color.TRANSPARENT); imageView.setId(R.id.drag_and_drop_list_view_image_view); Bitmap glowingBitmap = Bitmap.createBitmap(bitmap.getWidth() + 30, bitmap.getHeight() + 30, Bitmap.Config.ARGB_8888);/*from www. ja v a 2s .co m*/ Canvas glowingCanvas = new Canvas(glowingBitmap); Bitmap alpha = bitmap.extractAlpha(); Paint paintBlur = new Paint(); paintBlur.setColor(Color.WHITE); glowingCanvas.drawBitmap(alpha, 15, 15, paintBlur); BlurMaskFilter blurMaskFilter = new BlurMaskFilter(15.0f, BlurMaskFilter.Blur.OUTER); paintBlur.setMaskFilter(blurMaskFilter); glowingCanvas.drawBitmap(alpha, 15, 15, paintBlur); paintBlur.setMaskFilter(null); glowingCanvas.drawBitmap(bitmap, 15, 15, paintBlur); imageView.setImageBitmap(glowingBitmap); return imageView; }
From source file:hku.fyp14017.blencode.ui.fragment.AddBrickFragment.java
public ImageView getGlowingBorder(Bitmap bitmap) { ImageView imageView = new ImageView(getActivity()); imageView.setBackgroundColor(Color.TRANSPARENT); imageView.setId(hku.fyp14017.blencode.R.id.drag_and_drop_list_view_image_view); Bitmap glowingBitmap = Bitmap.createBitmap(bitmap.getWidth() + 30, bitmap.getHeight() + 30, Bitmap.Config.ARGB_8888);/* w w w.j av a2 s.c o m*/ Canvas glowingCanvas = new Canvas(glowingBitmap); Bitmap alpha = bitmap.extractAlpha(); Paint paintBlur = new Paint(); paintBlur.setColor(Color.WHITE); glowingCanvas.drawBitmap(alpha, 15, 15, paintBlur); BlurMaskFilter blurMaskFilter = new BlurMaskFilter(15.0f, BlurMaskFilter.Blur.OUTER); paintBlur.setMaskFilter(blurMaskFilter); glowingCanvas.drawBitmap(alpha, 15, 15, paintBlur); paintBlur.setMaskFilter(null); glowingCanvas.drawBitmap(bitmap, 15, 15, paintBlur); imageView.setImageBitmap(glowingBitmap); return imageView; }
From source file:com.acceleratedio.pac_n_zoom.DrawSVG.java
public ArrayList<ImageView> DrawSVG(Context context, ImageView orgnlImageView, RelativeLayout rel_anm_lo) { paint.setColor(Color.WHITE);//from w w w . j a v a 2s . c o m paint.setStyle(Paint.Style.FILL); LoadSVG.SVGData data = AnimActivity.svg_data; ArrayList<ImageView> imgViews = new ArrayList<ImageView>(); imgViews.add(orgnlImageView); if (data.symbl != null) { ArrayList<String> sprt_ordr = data.svg.ordr; int sym_mbr = 0; Bitmap bitmap; Canvas canvas; // - Loop through the sprites int sprt_nmbr = sprt_ordr.size(); data.svg.initScl = new float[sprt_nmbr]; float[] initScl = data.svg.initScl; for (int sprt_mbr = 1; sprt_mbr < sprt_nmbr; sprt_mbr += 1) { String sprt_id = sprt_ordr.get(sprt_mbr); // e.g., id="g2_0" if (Integer.parseInt(sprt_id.substring(sprt_id.indexOf('_') + 1)) > 0) { // The symbol is already drawn; replicate the view String init_sprt = sprt_id.substring(0, sprt_id.indexOf('_') + 1) + '0'; String svg_ordr = data.svg.svg_ordr; String cnt_str = svg_ordr.substring(0, svg_ordr.indexOf(init_sprt)); ImageView init_vw = imgViews.get(StringUtils.countMatches(cnt_str, ",")); Bitmap initBmp = ((BitmapDrawable) init_vw.getDrawable()).getBitmap(); bitmap = Bitmap.createBitmap(initBmp.getWidth(), initBmp.getHeight(), initBmp.getConfig()); canvas = new Canvas(bitmap); canvas.save(Canvas.MATRIX_SAVE_FLAG); xfrmInit crt_sprt = getInitSpriteAttrib(sprt_id); canvas.scale(crt_sprt.scl, crt_sprt.scl); initScl[sprt_mbr] = crt_sprt.scl; canvas.translate(0, 0); } else { // The symbol needs to be drawn; a new view is used bitmap = getCreatBmp(rel_anm_lo); canvas = new Canvas(bitmap); canvas.save(Canvas.MATRIX_SAVE_FLAG); // - Set the init values xfrmInit crt_sprt = getInitSpriteAttrib(sprt_id); canvas.scale(crt_sprt.scl, crt_sprt.scl); initScl[sprt_mbr] = crt_sprt.scl; canvas.translate(0, 0); // - Draw the bitmap LoadSVG.symbol crt_sym = data.symbl.get(sym_mbr); ArrayList<LoadSVG.path> pths = crt_sym.pths; int pth_nmbr = pths.size(); // Loop through the paths for (int pth_mbr = 0; pth_mbr < pth_nmbr; pth_mbr += 1) { LoadSVG.path crt_pth = pths.get(pth_mbr); final Path path = new Path(); final Paint paint = new Paint(); /* Debug if (pth_mbr + 1 == pth_nmbr) { String log_str = "Paths: pth_mbr = " + String.valueOf(pth_mbr) + "; color = " + crt_pth.clr; Log.d("DrawSVG", log_str); } */ paint.setColor(Color.parseColor(crt_pth.clr)); paint.setAntiAlias(true); paint.setStyle(Paint.Style.FILL_AND_STROKE); ld_pth_pnts(crt_pth.pth, path); path.close(); path.setFillType(Path.FillType.EVEN_ODD); canvas.drawPath(path, paint); } canvas.restore(); sym_mbr += 1; } ImageView iv = new ImageView(context); iv.setImageBitmap(bitmap); RelativeLayout.LayoutParams rlp = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT); iv.draw(canvas); iv.setLayoutParams(rlp); iv.setBackgroundColor(Color.TRANSPARENT); imgViews.add(iv); } // sprites } // if symbol return imgViews; }
From source file:com.android.inputmethod.keyboard.emoji.EmojiPalettesView.java
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);//w ww.j a va 2 s .c om host.addTab(tspec); }
From source file:com.keylesspalace.tusky.MainActivity.java
private void setupDrawer() { headerResult = new AccountHeaderBuilder().withActivity(this).withDividerBelowHeader(false) .withHeaderBackgroundScaleType(ImageView.ScaleType.CENTER_CROP).withCurrentProfileHiddenInList(true) .withOnAccountHeaderListener((view, profile, current) -> handleProfileClick(profile, current)) .addProfiles(new ProfileSettingDrawerItem().withIdentifier(DRAWER_ITEM_ADD_ACCOUNT) .withName(R.string.add_account_name).withDescription(R.string.add_account_description) .withIcon(GoogleMaterial.Icon.gmd_add)) .build();// w w w .j a va 2 s. c o m headerResult.getView().findViewById(R.id.material_drawer_account_header_current) .setContentDescription(getString(R.string.action_view_profile)); ImageView background = headerResult.getHeaderBackgroundView(); background.setColorFilter(ContextCompat.getColor(this, R.color.header_background_filter)); background.setBackgroundColor(ContextCompat.getColor(this, R.color.window_background_dark)); DrawerImageLoader.init(new AbstractDrawerImageLoader() { @Override public void set(ImageView imageView, Uri uri, Drawable placeholder, String tag) { Picasso.with(imageView.getContext()).load(uri).placeholder(placeholder).into(imageView); } @Override public void cancel(ImageView imageView) { Picasso.with(imageView.getContext()).cancelRequest(imageView); } }); VectorDrawableCompat muteDrawable = VectorDrawableCompat.create(getResources(), R.drawable.ic_mute_24dp, getTheme()); ThemeUtils.setDrawableTint(this, muteDrawable, R.attr.toolbar_icon_tint); List<IDrawerItem> listItems = new ArrayList<>(11); listItems.add(new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_EDIT_PROFILE) .withName(R.string.action_edit_profile).withSelectable(false) .withIcon(GoogleMaterial.Icon.gmd_person)); listItems.add(new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_FAVOURITES) .withName(R.string.action_view_favourites).withSelectable(false) .withIcon(GoogleMaterial.Icon.gmd_star)); listItems.add(new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_LISTS).withName(R.string.action_lists) .withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_list)); listItems.add(new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_MUTED_USERS) .withName(R.string.action_view_mutes).withSelectable(false).withIcon(muteDrawable)); listItems.add(new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_BLOCKED_USERS) .withName(R.string.action_view_blocks).withSelectable(false) .withIcon(GoogleMaterial.Icon.gmd_block)); listItems.add(new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_SEARCH).withName(R.string.action_search) .withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_search)); listItems.add(new PrimaryDrawerItem().withIdentifier(DRAWER_ITEM_SAVED_TOOT) .withName(R.string.action_access_saved_toot).withSelectable(false) .withIcon(GoogleMaterial.Icon.gmd_save)); listItems.add(new DividerDrawerItem()); listItems.add(new SecondaryDrawerItem().withIdentifier(DRAWER_ITEM_PREFERENCES) .withName(R.string.action_view_preferences).withSelectable(false) .withIcon(GoogleMaterial.Icon.gmd_settings)); listItems.add( new SecondaryDrawerItem().withIdentifier(DRAWER_ITEM_ABOUT).withName(R.string.about_title_activity) .withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_info)); listItems.add(new SecondaryDrawerItem().withIdentifier(DRAWER_ITEM_LOG_OUT).withName(R.string.action_logout) .withSelectable(false).withIcon(GoogleMaterial.Icon.gmd_exit_to_app)); drawer = new DrawerBuilder().withActivity(this).withAccountHeader(headerResult).withHasStableIds(true) .withSelectedItem(-1).withDrawerItems(listItems) .withOnDrawerItemClickListener((view, position, drawerItem) -> { if (drawerItem != null) { long drawerItemIdentifier = drawerItem.getIdentifier(); if (drawerItemIdentifier == DRAWER_ITEM_EDIT_PROFILE) { Intent intent = new Intent(MainActivity.this, EditProfileActivity.class); startActivityWithSlideInAnimation(intent); } else if (drawerItemIdentifier == DRAWER_ITEM_FAVOURITES) { Intent intent = new Intent(MainActivity.this, FavouritesActivity.class); startActivityWithSlideInAnimation(intent); } else if (drawerItemIdentifier == DRAWER_ITEM_MUTED_USERS) { Intent intent = new Intent(MainActivity.this, AccountListActivity.class); intent.putExtra("type", AccountListActivity.Type.MUTES); startActivityWithSlideInAnimation(intent); } else if (drawerItemIdentifier == DRAWER_ITEM_BLOCKED_USERS) { Intent intent = new Intent(MainActivity.this, AccountListActivity.class); intent.putExtra("type", AccountListActivity.Type.BLOCKS); startActivityWithSlideInAnimation(intent); } else if (drawerItemIdentifier == DRAWER_ITEM_SEARCH) { Intent intent = new Intent(MainActivity.this, SearchActivity.class); startActivityWithSlideInAnimation(intent); } else if (drawerItemIdentifier == DRAWER_ITEM_PREFERENCES) { Intent intent = new Intent(MainActivity.this, PreferencesActivity.class); startActivityWithSlideInAnimation(intent); } else if (drawerItemIdentifier == DRAWER_ITEM_ABOUT) { Intent intent = new Intent(MainActivity.this, AboutActivity.class); startActivityWithSlideInAnimation(intent); } else if (drawerItemIdentifier == DRAWER_ITEM_LOG_OUT) { logout(); } else if (drawerItemIdentifier == DRAWER_ITEM_FOLLOW_REQUESTS) { Intent intent = new Intent(MainActivity.this, AccountListActivity.class); intent.putExtra("type", AccountListActivity.Type.FOLLOW_REQUESTS); startActivityWithSlideInAnimation(intent); } else if (drawerItemIdentifier == DRAWER_ITEM_SAVED_TOOT) { Intent intent = new Intent(MainActivity.this, SavedTootActivity.class); startActivityWithSlideInAnimation(intent); } else if (drawerItemIdentifier == DRAWER_ITEM_LISTS) { startActivityWithSlideInAnimation(ListsActivity.newIntent(this)); } } return false; }).build(); if (BuildConfig.DEBUG) { IDrawerItem debugItem = new SecondaryDrawerItem().withIdentifier(1337).withName("debug") .withDisabledTextColor(Color.GREEN).withSelectable(false).withEnabled(false); drawer.addItem(debugItem); } updateProfiles(); }
From source file:com.chen.mail.ui.NestedFolderTeaserView.java
/** * Creates a {@link FolderHolder}./*from w w w . ja v a2 s. c om*/ */ private FolderHolder createFolderHolder(final CharSequence folderName) { final View itemView = LayoutInflater.from(getContext()).inflate(R.layout.folder_teaser_item, null); final ImageView imageView = (ImageView) itemView.findViewById(R.id.folder_imageView); imageView.setImageResource(R.drawable.ic_menu_folders_holo_light); // Remove background imageView.setBackgroundColor(Color.TRANSPARENT); ((TextView) itemView.findViewById(R.id.folder_textView)).setText(folderName); final TextView sendersTextView = (TextView) itemView.findViewById(R.id.senders_textView); final TextView countTextView = (TextView) itemView.findViewById(R.id.count_textView); final FolderHolder holder = new FolderHolder(itemView, sendersTextView, countTextView); attachOnClickListener(itemView, holder); return holder; }
From source file:org.matrix.androidsdk.db.MXMediaWorkerTask.java
@Override protected void onPostExecute(Bitmap bitmap) { if (null != mErrorAsJsonElement) { sendError(mErrorAsJsonElement);//www . j a v a 2s .c o m } sendDownloadComplete(); // update the imageView image if (bitmap != null) { for (WeakReference<ImageView> weakRef : mImageViewReferences) { final ImageView imageView = weakRef.get(); if (imageView != null && TextUtils.equals(mUrl, (String) imageView.getTag())) { imageView.setBackgroundColor(Color.TRANSPARENT); imageView.setImageBitmap(bitmap); } } } }
From source file:com.example.android.displayingbitmaps.imageloader.ImageWorker.java
/** * Load an image specified by the data parameter into an ImageView (override * {@link ImageWorker#processBitmap(Object)} to define the processing logic). A memory and * disk cache will be used if an {@link ImageCache} has been added using * {@link ImageWorker#addImageCache(android.support.v4.app.FragmentManager, ImageCache.ImageCacheParams)}. If the * image is found in the memory cache, it is set immediately, otherwise an {@link AsyncTask} * will be created to asynchronously load the bitmap. * * @param data The URI of the image./*from w w w. j a v a 2 s . com*/ * @param imageView The ImageView to bind the downloaded image to. */ public void loadImage(Object data, ImageView imageView) { if (data == null) { return; } BitmapDrawable value = null; if (mImageCache != null) { value = mImageCache.getBitmapFromMemCache(String.valueOf(data)); } if (value != null) { // Bitmap found in memory cache imageView.setImageDrawable(value); imageView.setBackgroundColor(Color.TRANSPARENT); } else if (cancelPotentialWork(data, imageView)) { //BEGIN_INCLUDE(execute_background_task) final BitmapWorkerTask task = new BitmapWorkerTask(data, imageView); final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task); imageView.setImageDrawable(asyncDrawable); // NOTE: This uses a custom version of AsyncTask that has been pulled from the // framework and slightly modified. Refer to the docs at the top of the class // for more info on what was changed. task.executeOnExecutor(AsyncTask.DUAL_THREAD_EXECUTOR); //END_INCLUDE(execute_background_task) } }
From source file:image_cache.ImageWorker.java
/** * Load an image specified by the data parameter into an ImageView (override * {@link ImageWorker#processBitmap(Object)} to define the processing * logic). A memory and disk cache will be used if an {@link ImageCache} has * been set using {@link ImageWorker#setImageCache(ImageCache)}. If the * image is found in the memory cache, it is set immediately, otherwise an * {@link ImageTask} will be created to asynchronously load the bitmap. * /* w ww. ja va 2 s. c om*/ * @param data * The URL of the image to download. * @param imageView * The ImageView to bind the downloaded image to. */ public void loadImage(Object data, ImageView imageView) { if (data == null) { return; } Bitmap bitmap = null; if (mImageCache != null) { bitmap = mImageCache.getBitmapFromMemCache(String.valueOf(data)); } if (bitmap != null) { // Bitmap found in memory cache imageView.setImageBitmap(bitmap); imageView.setBackgroundColor(0); } else if (cancelPotentialWork(data, imageView)) { final BitmapWorkerTask task = new BitmapWorkerTask(imageView); final AsyncDrawable asyncDrawable = new AsyncDrawable(mResources, mLoadingBitmap, task); imageView.setImageDrawable(asyncDrawable); // NOTE: This uses a custom version of AsyncTask that has been // pulled from the // framework and slightly modified. Refer to the docs at the top of // the class // for more info on what was changed. task.executeOnExecutor(ImageTask.DUAL_THREAD_EXECUTOR, data); } }