Example usage for android.graphics.drawable RippleDrawable setState

List of usage examples for android.graphics.drawable RippleDrawable setState

Introduction

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

Prototype

public boolean setState(@NonNull final int[] stateSet) 

Source Link

Document

Specify a set of states for the drawable.

Usage

From source file:com.winneredge.stockly.wcommons.floatingactionwidget.FloatingActionButton.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionDown() {
    if (mBackgroundDrawable instanceof StateListDrawable) {
        StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
        drawable.setState(new int[] { android.R.attr.state_enabled, android.R.attr.state_pressed });
    } else if (Util.hasLollipop()) {
        RippleDrawable ripple = (RippleDrawable) mBackgroundDrawable;
        ripple.setState(new int[] { android.R.attr.state_enabled, android.R.attr.state_pressed });
        ripple.setHotspot(calculateCenterX(), calculateCenterY());
        ripple.setVisible(true, true);//ww  w.j  a  v a  2s .c  o  m
    }
}

From source file:com.winneredge.stockly.wcommons.floatingactionwidget.FloatingActionButton.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionUp() {
    if (mBackgroundDrawable instanceof StateListDrawable) {
        StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
        drawable.setState(new int[] { android.R.attr.state_enabled });
    } else if (Util.hasLollipop()) {
        RippleDrawable ripple = (RippleDrawable) mBackgroundDrawable;
        ripple.setState(new int[] { android.R.attr.state_enabled });
        ripple.setHotspot(calculateCenterX(), calculateCenterY());
        ripple.setVisible(true, true);//from w  ww .  ja v  a 2  s  . c om
    }
}