Search in sources :

Example 11 with InsetDrawable

use of android.graphics.drawable.InsetDrawable in project SublimePicker by vikramkakkar.

the class SUtils method createButtonShape.

// Base button shape
private static Drawable createButtonShape(Context context, int color) {
    // Translation of Lollipop's xml button-bg definition to Java
    int paddingH = context.getResources().getDimensionPixelSize(R.dimen.button_padding_horizontal_material);
    int paddingV = context.getResources().getDimensionPixelSize(R.dimen.button_padding_vertical_material);
    int insetH = context.getResources().getDimensionPixelSize(R.dimen.button_inset_horizontal_material);
    int insetV = context.getResources().getDimensionPixelSize(R.dimen.button_inset_vertical_material);
    float[] outerRadii = new float[8];
    Arrays.fill(outerRadii, CORNER_RADIUS);
    RoundRectShape r = new RoundRectShape(outerRadii, null, null);
    ShapeDrawable shapeDrawable = new ShapeDrawable(r);
    shapeDrawable.getPaint().setColor(color);
    shapeDrawable.setPadding(paddingH, paddingV, paddingH, paddingV);
    return new InsetDrawable(shapeDrawable, insetH, insetV, insetH, insetV);
}
Also used : RoundRectShape(android.graphics.drawable.shapes.RoundRectShape) ShapeDrawable(android.graphics.drawable.ShapeDrawable) InsetDrawable(android.graphics.drawable.InsetDrawable)

Example 12 with InsetDrawable

use of android.graphics.drawable.InsetDrawable in project wire-android by wireapp.

the class AddPhoneNumberPreferenceDialogFragment method clearColorFilter.

// from TextInputLayout
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void clearColorFilter(@NonNull Drawable drawable) {
    drawable.clearColorFilter();
    if (Build.VERSION.SDK_INT == 21 || Build.VERSION.SDK_INT == 22) {
        // children manually
        if (drawable instanceof InsetDrawable) {
            clearColorFilter(((InsetDrawable) drawable).getDrawable());
        } else if (drawable instanceof DrawableWrapper) {
            clearColorFilter(((DrawableWrapper) drawable).getWrappedDrawable());
        } else if (drawable instanceof DrawableContainer) {
            final DrawableContainer container = (DrawableContainer) drawable;
            final DrawableContainer.DrawableContainerState state = (DrawableContainer.DrawableContainerState) container.getConstantState();
            if (state != null) {
                for (int i = 0, count = state.getChildCount(); i < count; i++) {
                    clearColorFilter(state.getChild(i));
                }
            }
        }
    }
}
Also used : DrawableWrapper(android.support.v4.graphics.drawable.DrawableWrapper) InsetDrawable(android.graphics.drawable.InsetDrawable) DrawableContainer(android.graphics.drawable.DrawableContainer) SuppressLint(android.annotation.SuppressLint) TargetApi(android.annotation.TargetApi)

Aggregations

InsetDrawable (android.graphics.drawable.InsetDrawable)12 Drawable (android.graphics.drawable.Drawable)6 LayerDrawable (android.graphics.drawable.LayerDrawable)4 StateListDrawable (android.graphics.drawable.StateListDrawable)4 TypedArray (android.content.res.TypedArray)3 ShapeDrawable (android.graphics.drawable.ShapeDrawable)3 Attributes (com.cengalabs.flatui.Attributes)3 Typeface (android.graphics.Typeface)2 GradientDrawable (android.graphics.drawable.GradientDrawable)2 PaintDrawable (android.graphics.drawable.PaintDrawable)2 RoundRectShape (android.graphics.drawable.shapes.RoundRectShape)2 SuppressLint (android.annotation.SuppressLint)1 TargetApi (android.annotation.TargetApi)1 Bitmap (android.graphics.Bitmap)1 Rect (android.graphics.Rect)1 AnimationDrawable (android.graphics.drawable.AnimationDrawable)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 DrawableContainer (android.graphics.drawable.DrawableContainer)1 OvalShape (android.graphics.drawable.shapes.OvalShape)1 DrawableWrapper (android.support.v4.graphics.drawable.DrawableWrapper)1