Search in sources :

Example 56 with BitmapDrawable

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);
}
Also used : ImageView(android.widget.ImageView) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 57 with BitmapDrawable

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);
}
Also used : TransitionDrawable(android.graphics.drawable.TransitionDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) ImageView(android.widget.ImageView)

Example 58 with BitmapDrawable

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;
}
Also used : Bitmap(android.graphics.Bitmap) FrameLayout(android.widget.FrameLayout) BitmapDrawable(android.graphics.drawable.BitmapDrawable) SuppressLint(android.annotation.SuppressLint) SuppressLint(android.annotation.SuppressLint)

Example 59 with BitmapDrawable

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;
}
Also used : Bitmap(android.graphics.Bitmap) DrawableWrapper(android.support.v4.graphics.drawable.DrawableWrapper) LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) AnimationDrawable(android.graphics.drawable.AnimationDrawable) Drawable(android.graphics.drawable.Drawable) ClipDrawable(android.graphics.drawable.ClipDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) BitmapShader(android.graphics.BitmapShader) ClipDrawable(android.graphics.drawable.ClipDrawable)

Example 60 with BitmapDrawable

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);
    }
}
Also used : BitmapDrawable(android.graphics.drawable.BitmapDrawable) NavigationView(android.support.design.widget.NavigationView) BindView(butterknife.BindView) View(android.view.View) ActionMenuView(android.support.v7.widget.ActionMenuView) TextView(android.widget.TextView) File(java.io.File) LinearLayout(android.widget.LinearLayout)

Aggregations

BitmapDrawable (android.graphics.drawable.BitmapDrawable)640 Bitmap (android.graphics.Bitmap)426 Drawable (android.graphics.drawable.Drawable)187 Canvas (android.graphics.Canvas)182 Paint (android.graphics.Paint)110 Rect (android.graphics.Rect)77 View (android.view.View)77 ImageView (android.widget.ImageView)63 ColorDrawable (android.graphics.drawable.ColorDrawable)59 TextView (android.widget.TextView)51 IOException (java.io.IOException)40 Resources (android.content.res.Resources)35 LayerDrawable (android.graphics.drawable.LayerDrawable)33 AnimationDrawable (android.graphics.drawable.AnimationDrawable)30 File (java.io.File)27 Test (org.junit.Test)24 Matrix (android.graphics.Matrix)23 Intent (android.content.Intent)22 StateListDrawable (android.graphics.drawable.StateListDrawable)22 InputStream (java.io.InputStream)22