Example usage for android.graphics.drawable GradientDrawable invalidateSelf

List of usage examples for android.graphics.drawable GradientDrawable invalidateSelf

Introduction

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

Prototype

public void invalidateSelf() 

Source Link

Document

Use the current Callback implementation to have this Drawable redrawn.

Usage

From source file:com.forrestguice.suntimeswidget.LightMapDialog.java

private void colorizeImageView(ImageView view, int color) {
    if (view.getBackground() != null) {
        GradientDrawable d = (GradientDrawable) view.getBackground().mutate();
        d.setColor(color);//from   w w  w.  java2 s.  c om
        d.invalidateSelf();
    }
}

From source file:com.forrestguice.suntimeswidget.settings.ColorChooser.java

private void updateViews() {
    if (edit != null) {
        edit.setText(String.format("#%08X", color));
        edit.setVisibility((isCollapsed ? View.GONE : View.VISIBLE));
    }/*from  w  w w  .j a  va  2  s  . c o m*/

    if (button != null) {
        Drawable d = button.getDrawable();
        if (d != null) {
            GradientDrawable g = (GradientDrawable) d.mutate();
            g.setColor(color);
            g.invalidateSelf();
        }
    }
}