Search in sources :

Example 1 with LayerDrawable

use of android.graphics.drawable.LayerDrawable in project nmid-headline by miao1007.

the class EditPage method genBackground.

private void genBackground() {
    background = new ColorDrawable(DIM_COLOR);
    if (backgroundView != null) {
        try {
            Bitmap bgBm = captureView(backgroundView, backgroundView.getWidth(), backgroundView.getHeight());
            bgBm = blur(bgBm, 20, 8);
            BitmapDrawable blurBm = new BitmapDrawable(activity.getResources(), bgBm);
            background = new LayerDrawable(new Drawable[] { blurBm, background });
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}
Also used : Bitmap(android.graphics.Bitmap) ColorDrawable(android.graphics.drawable.ColorDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 2 with LayerDrawable

use of android.graphics.drawable.LayerDrawable in project Signal-Android by WhisperSystems.

the class ColorPreference method setColorViewValue.

private static void setColorViewValue(View view, int color, boolean selected) {
    if (view instanceof ImageView) {
        ImageView imageView = (ImageView) view;
        Resources res = imageView.getContext().getResources();
        Drawable currentDrawable = imageView.getDrawable();
        GradientDrawable colorChoiceDrawable;
        if (currentDrawable instanceof GradientDrawable) {
            // Reuse drawable
            colorChoiceDrawable = (GradientDrawable) currentDrawable;
        } else {
            colorChoiceDrawable = new GradientDrawable();
            colorChoiceDrawable.setShape(GradientDrawable.OVAL);
        }
        // Set stroke to dark version of color
        //      int darkenedColor = Color.rgb(
        //          Color.red(color) * 192 / 256,
        //          Color.green(color) * 192 / 256,
        //          Color.blue(color) * 192 / 256);
        colorChoiceDrawable.setColor(color);
        //      colorChoiceDrawable.setStroke((int) TypedValue.applyDimension(
        //          TypedValue.COMPLEX_UNIT_DIP, 2, res.getDisplayMetrics()), darkenedColor);
        Drawable drawable = colorChoiceDrawable;
        if (selected) {
            BitmapDrawable checkmark = (BitmapDrawable) res.getDrawable(R.drawable.check);
            checkmark.setGravity(Gravity.CENTER);
            drawable = new LayerDrawable(new Drawable[] { colorChoiceDrawable, checkmark });
        }
        imageView.setImageDrawable(drawable);
    } else if (view instanceof TextView) {
        ((TextView) view).setTextColor(color);
    }
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Drawable(android.graphics.drawable.Drawable) GradientDrawable(android.graphics.drawable.GradientDrawable) TextView(android.widget.TextView) ImageView(android.widget.ImageView) Resources(android.content.res.Resources) BitmapDrawable(android.graphics.drawable.BitmapDrawable) GradientDrawable(android.graphics.drawable.GradientDrawable)

Example 3 with LayerDrawable

use of android.graphics.drawable.LayerDrawable in project remusic by aa112901.

the class AppCompatProgressBarHelper method getTintTarget.

@Nullable
private Drawable getTintTarget(int layerId, boolean shouldFallback) {
    Drawable layer = null;
    final Drawable d = ((ProgressBar) mView).getProgressDrawable();
    if (d != null) {
        ((ProgressBar) mView).setProgressDrawable(d.mutate());
        if (d instanceof LayerDrawable) {
            layer = ((LayerDrawable) d).findDrawableByLayerId(layerId);
        }
        if (shouldFallback && layer == null) {
            layer = d;
        }
    }
    return layer;
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) LayerDrawable(android.graphics.drawable.LayerDrawable) Drawable(android.graphics.drawable.Drawable) ProgressBar(android.widget.ProgressBar) Nullable(android.support.annotation.Nullable)

Example 4 with LayerDrawable

use of android.graphics.drawable.LayerDrawable in project android_frameworks_base by ParanoidAndroid.

the class TabletStatusBar method workAroundBadLayerDrawableOpacity.

@Override
protected void workAroundBadLayerDrawableOpacity(View v) {
    Drawable bgd = v.getBackground();
    if (!(bgd instanceof LayerDrawable))
        return;
    LayerDrawable d = (LayerDrawable) bgd;
    v.setBackground(null);
    d.setOpacity(PixelFormat.TRANSLUCENT);
    v.setBackground(d);
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable) Drawable(android.graphics.drawable.Drawable) LayerDrawable(android.graphics.drawable.LayerDrawable)

Example 5 with LayerDrawable

use of android.graphics.drawable.LayerDrawable in project android_frameworks_base by ResurrectionRemix.

the class ToggleButton method updateReferenceToIndicatorDrawable.

private void updateReferenceToIndicatorDrawable(Drawable backgroundDrawable) {
    if (backgroundDrawable instanceof LayerDrawable) {
        LayerDrawable layerDrawable = (LayerDrawable) backgroundDrawable;
        mIndicatorDrawable = layerDrawable.findDrawableByLayerId(com.android.internal.R.id.toggle);
    } else {
        mIndicatorDrawable = null;
    }
}
Also used : LayerDrawable(android.graphics.drawable.LayerDrawable)

Aggregations

LayerDrawable (android.graphics.drawable.LayerDrawable)213 Drawable (android.graphics.drawable.Drawable)141 BitmapDrawable (android.graphics.drawable.BitmapDrawable)65 StateListDrawable (android.graphics.drawable.StateListDrawable)64 ShapeDrawable (android.graphics.drawable.ShapeDrawable)50 ClipDrawable (android.graphics.drawable.ClipDrawable)45 AnimationDrawable (android.graphics.drawable.AnimationDrawable)44 GradientDrawable (android.graphics.drawable.GradientDrawable)39 Paint (android.graphics.Paint)32 SuppressLint (android.annotation.SuppressLint)23 ColorDrawable (android.graphics.drawable.ColorDrawable)23 Bitmap (android.graphics.Bitmap)16 BitmapShader (android.graphics.BitmapShader)14 TextView (android.widget.TextView)14 View (android.view.View)13 OvalShape (android.graphics.drawable.shapes.OvalShape)11 RippleDrawable (android.graphics.drawable.RippleDrawable)10 ImageView (android.widget.ImageView)10 Resources (android.content.res.Resources)9 TypedArray (android.content.res.TypedArray)8