use of android.graphics.drawable.BitmapDrawable in project afinal by yangfuhai.
the class SimpleDisplayer method animationDisplay.
private void animationDisplay(View imageView, Bitmap bitmap, Animation animation) {
animation.setStartTime(AnimationUtils.currentAnimationTimeMillis());
if (imageView instanceof ImageView) {
((ImageView) imageView).setImageBitmap(bitmap);
} else {
imageView.setBackgroundDrawable(new BitmapDrawable(bitmap));
}
imageView.startAnimation(animation);
}
use of android.graphics.drawable.BitmapDrawable in project afinal by yangfuhai.
the class SimpleDisplayer method fadeInDisplay.
private void fadeInDisplay(View imageView, Bitmap bitmap) {
final TransitionDrawable td = new TransitionDrawable(new Drawable[] { new ColorDrawable(android.R.color.transparent), new BitmapDrawable(imageView.getResources(), bitmap) });
if (imageView instanceof ImageView) {
((ImageView) imageView).setImageDrawable(td);
} else {
imageView.setBackgroundDrawable(td);
}
td.startTransition(300);
}
use of android.graphics.drawable.BitmapDrawable in project ZI by yixia.
the class Crouton method initializeCroutonViewGroup.
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
private FrameLayout initializeCroutonViewGroup(Resources resources) {
FrameLayout croutonView = new FrameLayout(this.activity);
if (null != onClickListener)
croutonView.setOnClickListener(onClickListener);
final int height;
if (this.style.heightDimensionResId > 0) {
height = resources.getDimensionPixelSize(this.style.heightDimensionResId);
} else {
height = this.style.heightInPixels;
}
final int width;
if (this.style.widthDimensionResId > 0) {
width = resources.getDimensionPixelSize(this.style.widthDimensionResId);
} else {
width = this.style.widthInPixels;
}
croutonView.setLayoutParams(new FrameLayout.LayoutParams(width != 0 ? width : FrameLayout.LayoutParams.MATCH_PARENT, height));
// set background
if (this.style.backgroundColorValue != -1) {
croutonView.setBackgroundColor(this.style.backgroundColorValue);
} else {
croutonView.setBackgroundColor(resources.getColor(this.style.backgroundColorResourceId));
}
// color.
if (this.style.backgroundDrawableResourceId != 0) {
Bitmap background = BitmapFactory.decodeResource(resources, this.style.backgroundDrawableResourceId);
BitmapDrawable drawable = new BitmapDrawable(resources, background);
if (this.style.isTileEnabled) {
drawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);
}
int sdk = android.os.Build.VERSION.SDK_INT;
if (sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
croutonView.setBackgroundDrawable(drawable);
} else {
croutonView.setBackground(drawable);
}
}
return croutonView;
}
use of android.graphics.drawable.BitmapDrawable in project Android-skin-support by ximsfei.
the class SkinCompatProgressBarHelper method tileify.
/**
* Converts a drawable to a tiled version of itself. It will recursively
* traverse layer and state list drawables.
*/
private Drawable tileify(Drawable drawable, boolean clip) {
if (drawable instanceof DrawableWrapper) {
Drawable inner = ((DrawableWrapper) drawable).getWrappedDrawable();
if (inner != null) {
inner = tileify(inner, clip);
((DrawableWrapper) drawable).setWrappedDrawable(inner);
}
} else if (drawable instanceof LayerDrawable) {
LayerDrawable background = (LayerDrawable) drawable;
final int N = background.getNumberOfLayers();
Drawable[] outDrawables = new Drawable[N];
for (int i = 0; i < N; i++) {
int id = background.getId(i);
outDrawables[i] = tileify(background.getDrawable(i), (id == android.R.id.progress || id == android.R.id.secondaryProgress));
}
LayerDrawable newBg = new LayerDrawable(outDrawables);
for (int i = 0; i < N; i++) {
newBg.setId(i, background.getId(i));
}
return newBg;
} else if (drawable instanceof BitmapDrawable) {
final BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
final Bitmap tileBitmap = bitmapDrawable.getBitmap();
if (mSampleTile == null) {
mSampleTile = tileBitmap;
}
final ShapeDrawable shapeDrawable = new ShapeDrawable(getDrawableShape());
final BitmapShader bitmapShader = new BitmapShader(tileBitmap, Shader.TileMode.REPEAT, Shader.TileMode.CLAMP);
shapeDrawable.getPaint().setShader(bitmapShader);
shapeDrawable.getPaint().setColorFilter(bitmapDrawable.getPaint().getColorFilter());
return (clip) ? new ClipDrawable(shapeDrawable, Gravity.LEFT, ClipDrawable.HORIZONTAL) : shapeDrawable;
}
return drawable;
}
use of android.graphics.drawable.BitmapDrawable in project LookLook by xinghongfei.
the class MainActivity method getPic.
@Override
public void getPic() {
View headerLayout = navView.getHeaderView(0);
LinearLayout llImage = (LinearLayout) headerLayout.findViewById(R.id.side_image);
if (new File(getFilesDir().getPath() + "/bg.jpg").exists()) {
BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), getFilesDir().getPath() + "/bg.jpg");
llImage.setBackground(bitmapDrawable);
}
}
Aggregations