List of usage examples for android.graphics.drawable BitmapDrawable setColorFilter
@Override public void setColorFilter(ColorFilter colorFilter)
From source file:com.me.harris.listviewitemanimations._01_activityAnim.ActivityAnimations.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_animations); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*w w w. j a v a 2 s . c om*/ getSupportActionBar().setTitle(""); handleStatusBar(); // Grayscale filter used on all thumbnails ColorMatrix grayMatrix = new ColorMatrix(); grayMatrix.setSaturation(0); ColorMatrixColorFilter grayscaleFilter = new ColorMatrixColorFilter(grayMatrix); mGridLayout = (GridLayout) findViewById(R.id.gridLayout); mGridLayout.setColumnCount(3); mGridLayout.setUseDefaultMargins(true); // add all photo thumbnails to layout Resources resources = getResources(); ArrayList<PictureData> pictures = mBitmapUtils.loadPhotos(resources); for (int i = 0; i < pictures.size(); ++i) { PictureData pictureData = pictures.get(i); BitmapDrawable thumbnailDrawable = new BitmapDrawable(resources, pictureData.thumbnail); thumbnailDrawable.setColorFilter(grayscaleFilter); ImageView imageView = new ImageView(this); imageView.setOnClickListener(thumbnailClickListener); imageView.setImageDrawable(thumbnailDrawable); mPicturesData.put(imageView, pictureData); mGridLayout.addView(imageView); } }
From source file:org.xbmc.kore.ui.RemoteFragment.java
@TargetApi(21) private void adjustRemoteButtons() { Resources.Theme theme = getActivity().getTheme(); TypedArray styledAttributes = theme.obtainStyledAttributes( new int[] { R.attr.remoteButtonColorFilter, R.attr.contentBackgroundColor }); // R.attr.remoteBackgroundColorFilter}); Resources resources = getResources(); int remoteButtonsColor = styledAttributes.getColor(styledAttributes.getIndex(0), resources.getColor(R.color.white)), remoteBackgroundColor = styledAttributes.getColor(styledAttributes.getIndex(1), resources.getColor(R.color.dark_content_background_dim_70pct)); styledAttributes.recycle();//from w w w . j a v a2s.c o m leftButton.setColorFilter(remoteButtonsColor); rightButton.setColorFilter(remoteButtonsColor); upButton.setColorFilter(remoteButtonsColor); downButton.setColorFilter(remoteButtonsColor); selectButton.setColorFilter(remoteButtonsColor); backButton.setColorFilter(remoteButtonsColor); infoButton.setColorFilter(remoteButtonsColor); osdButton.setColorFilter(remoteButtonsColor); contextButton.setColorFilter(remoteButtonsColor); // On ICS the remote background isn't shown as the tinting isn't supported //int backgroundResourceId = R.drawable.remote_background_square_black_alpha; int backgroundResourceId = R.drawable.remote_background_square_black; if (Utils.isLollipopOrLater()) { remotePanel.setBackgroundTintList(ColorStateList.valueOf(remoteBackgroundColor)); remotePanel.setBackgroundResource(backgroundResourceId); } else if (Utils.isJellybeanOrLater()) { BitmapDrawable background = new BitmapDrawable(getResources(), BitmapFactory.decodeResource(getResources(), backgroundResourceId)); background.setColorFilter(new PorterDuffColorFilter(remoteBackgroundColor, PorterDuff.Mode.SRC_IN)); remotePanel.setBackground(background); } }