本文整理汇总了Java中android.graphics.drawable.BitmapDrawable.setColorFilter方法的典型用法代码示例。如果您正苦于以下问题:Java BitmapDrawable.setColorFilter方法的具体用法?Java BitmapDrawable.setColorFilter怎么用?Java BitmapDrawable.setColorFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.drawable.BitmapDrawable
的用法示例。
在下文中一共展示了BitmapDrawable.setColorFilter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setBackground
import android.graphics.drawable.BitmapDrawable; //导入方法依赖的package包/类
public void setBackground(Activity activity) {
if (mImageCache.size() != 0) {
BitmapDrawable bd = new BitmapDrawable(activity.getResources(), mImageCache.get(CACHE_BLURRED_IMAGE));
bd.setAlpha(mAlpha);
if (mFilterColor != -1) {
bd.setColorFilter(mFilterColor, PorterDuff.Mode.DST_ATOP);
}
activity.getWindow().setBackgroundDrawable(bd);
mImageCache.remove(CACHE_BLURRED_IMAGE);
CacheBlurExecuteTask = null;
}
}
示例2: onCreate
import android.graphics.drawable.BitmapDrawable; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_animations);
// 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);
}
}
示例3: setBackground
import android.graphics.drawable.BitmapDrawable; //导入方法依赖的package包/类
public void setBackground(Activity activity) {
if (mImageCache.size() != 0) {
BitmapDrawable bd = new BitmapDrawable(activity.getResources(), mImageCache.get(KEY_CACHE_BLURRED_BACKGROUND_IMAGE));
bd.setAlpha(mAlpha);
if (mFilterColor != -1) {
bd.setColorFilter(mFilterColor, PorterDuff.Mode.DST_ATOP);
}
activity.getWindow().setBackgroundDrawable(bd);
mImageCache.remove(KEY_CACHE_BLURRED_BACKGROUND_IMAGE);
cacheBlurBehindAndExecuteTask = null;
}
}