Example usage for android.graphics.drawable ColorDrawable ColorDrawable

List of usage examples for android.graphics.drawable ColorDrawable ColorDrawable

Introduction

In this page you can find the example usage for android.graphics.drawable ColorDrawable ColorDrawable.

Prototype

public ColorDrawable(@ColorInt int color) 

Source Link

Document

Creates a new ColorDrawable with the specified color.

Usage

From source file:com.akalizakeza.apps.ishusho.activity.GlideUtil.java

public static void loadImage(String url, ImageView imageView) {
    Context context = imageView.getContext();
    ColorDrawable cd = new ColorDrawable(ContextCompat.getColor(context, R.color.colorPrimaryDark));
    Glide.with(context).load(url).placeholder(cd).crossFade().centerCrop().into(imageView);
}

From source file:Main.java

public static Dialog creativeDialog(Context context, int layout) {
    Dialog dialog = new Dialog(context, android.R.style.Theme_Holo_Light_Dialog);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    dialog.setContentView(layout);//  w ww.java2  s .  c o m
    return dialog;
}

From source file:Main.java

public static PopupWindow showPopWindow(Context context, View targetView, View contentView, Integer width) {
    PopupWindow popupWindow = null;//from w w w  . j  a v a  2 s .c  o  m
    popupWindow = new PopupWindow(contentView, -2, -2);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    if (width != null) {
        popupWindow.setWidth(width);
    }
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAsDropDown(targetView);
    return popupWindow;
}

From source file:Main.java

public static PopupWindow showPopWindow2(Context context, View targetView, View contentView, Integer width) {
    PopupWindow popupWindow = null;/*from w  w  w.ja  v a 2  s . c om*/
    popupWindow = new PopupWindow(contentView, -2, -2);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    if (width != null) {
        popupWindow.setWidth(width);
    }
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAtLocation(targetView, Gravity.BOTTOM, 0, 0);
    return popupWindow;
}

From source file:Main.java

public static PopupWindow showPopWindow3(Context context, View targetView, View contentView, Integer width) {
    PopupWindow popupWindow = null;//from   www.  j a v  a  2s.  co  m
    popupWindow = new PopupWindow(contentView, -2, -2);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
    if (width != null) {
        popupWindow.setWidth(width);
    }
    popupWindow.setOutsideTouchable(true);
    popupWindow.showAtLocation(targetView, Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL, 0, 0);
    return popupWindow;
}

From source file:Main.java

public static TransitionDrawable drawableToTransitionDrawable(Drawable drawable) {
    TransitionDrawable mBitmapDrawable = null;
    try {/*www.ja v a2  s.c o m*/
        if (drawable == null) {
            return null;
        }
        mBitmapDrawable = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), drawable });
    } catch (Exception e) {
        e.printStackTrace();
    }
    return mBitmapDrawable;
}

From source file:Main.java

public static TransitionDrawable drawableToTransitionDrawable(Drawable drawable) {
    TransitionDrawable mBitmapDrawable = null;
    try {/*from w  w w.j  a v a 2  s .c o m*/
        if (drawable == null) {
            return null;
        }
        mBitmapDrawable = new TransitionDrawable(new Drawable[] { new ColorDrawable(transparent), drawable });
    } catch (Exception e) {
        e.printStackTrace();
    }
    return mBitmapDrawable;
}

From source file:Main.java

public static TransitionDrawable bitmapToTransitionDrawable(Bitmap bitmap) {
    TransitionDrawable mBitmapDrawable = null;
    try {//from w w  w  .  ja  va 2 s .c  om
        if (bitmap == null) {
            return null;
        }
        mBitmapDrawable = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(android.R.color.transparent), new BitmapDrawable(bitmap) });
    } catch (Exception e) {
        e.printStackTrace();
    }
    return mBitmapDrawable;
}

From source file:Main.java

public static StateListDrawable toStateListDrawable(int normalColor, int pressedColor, int focusedColor,
        int unableColor) {
    StateListDrawable drawable = new StateListDrawable();
    Drawable normal = new ColorDrawable(normalColor);
    Drawable pressed = new ColorDrawable(pressedColor);
    Drawable focused = new ColorDrawable(focusedColor);
    Drawable unable = new ColorDrawable(unableColor);
    drawable.addState(new int[] { android.R.attr.state_pressed, android.R.attr.state_enabled }, pressed);
    drawable.addState(new int[] { android.R.attr.state_enabled, android.R.attr.state_focused }, focused);
    drawable.addState(new int[] { android.R.attr.state_enabled }, normal);
    drawable.addState(new int[] { android.R.attr.state_focused }, focused);
    drawable.addState(new int[] { android.R.attr.state_window_focused }, unable);
    drawable.addState(new int[] {}, normal);
    return drawable;
}

From source file:Main.java

public static TransitionDrawable bitmapToTransitionDrawable(Bitmap bitmap) {
    TransitionDrawable mBitmapDrawable = null;
    try {/*w  w w  . j  a v a  2  s .  c  o m*/
        if (bitmap == null) {
            return null;
        }
        mBitmapDrawable = new TransitionDrawable(
                new Drawable[] { new ColorDrawable(transparent), new BitmapDrawable(bitmap) });
    } catch (Exception e) {
        e.printStackTrace();
    }
    return mBitmapDrawable;
}