use of android.graphics.drawable.RippleDrawable in project Phonograph by kabouzeid.
the class ViewUtil method createSelectorDrawable.
public static Drawable createSelectorDrawable(Context context, @ColorInt int color) {
final StateListDrawable baseSelector = new StateListDrawable();
baseSelector.addState(new int[] { android.R.attr.state_activated }, new ColorDrawable(color));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
return new RippleDrawable(ColorStateList.valueOf(color), baseSelector, new ColorDrawable(Color.WHITE));
}
baseSelector.addState(new int[] {}, new ColorDrawable(Color.TRANSPARENT));
baseSelector.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(color));
return baseSelector;
}
use of android.graphics.drawable.RippleDrawable in project material-hijri-calendarview by eltohamy.
the class DayView method generateRippleDrawable.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static Drawable generateRippleDrawable(final int color) {
ColorStateList list = ColorStateList.valueOf(color);
Drawable mask = generateCircleDrawable(Color.WHITE);
return new RippleDrawable(list, null, mask);
}
use of android.graphics.drawable.RippleDrawable in project PhoneProfiles by henrichg.
the class ColorChooserPreferenceX method onBindViewHolder.
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
FrameLayout layout = (FrameLayout) holder.findViewById(R.id.dialog_color_chooser_pref_color);
int color = Integer.parseInt(value);
Drawable selector = createSelector(color);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int[][] states = new int[][] { new int[] { -android.R.attr.state_pressed }, new int[] { android.R.attr.state_pressed } };
int[] colors = new int[] { shiftColor(color), color };
ColorStateList rippleColors = new ColorStateList(states, colors);
setBackgroundCompat(layout, new RippleDrawable(rippleColors, selector, null));
} else {
setBackgroundCompat(layout, selector);
}
Handler handler = new Handler(context.getMainLooper());
handler.postDelayed(new Runnable() {
@Override
public void run() {
setSummary(R.string.empty_string);
}
}, 200);
}
use of android.graphics.drawable.RippleDrawable in project UIWidget by AriesHoo.
the class RadiusViewDelegate method init.
/**
* 设置shape属性
* 设置完所有属性后调用设置背景
*/
public void init() {
if (mView instanceof EditText) {
Log.i("v", "click:" + mView.isClickable() + ";enable:" + mView.isEnabled());
}
// 获取view当前drawable--用于判断是否通过默认属性设置背景
Drawable mDrawable = mView.getBackground();
// 判断是否使用自定义颜色值
boolean isSetBg = mBackgroundColor != Integer.MAX_VALUE || mBackgroundPressedColor != Integer.MAX_VALUE || mBackgroundDisabledColor != Integer.MAX_VALUE || mBackgroundSelectedColor != Integer.MAX_VALUE || mStrokeWidth > 0 || mRadius > 0 || mTopLeftRadius > 0 || mTopLeftRadius > 0 || mBottomLeftRadius > 0 || mBottomRightRadius > 0;
setDrawable(mBackgroundChecked, mBackgroundCheckedColor, mStrokeCheckedColor);
setDrawable(mBackgroundSelected, mBackgroundSelectedColor, mStrokeSelectedColor);
setDrawable(mBackground, mBackgroundColor, mStrokeColor);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && mRippleEnable && mView.isEnabled() && mView.isClickable()) {
// 5.0以上且设置水波属性并且可操作
RippleDrawable rippleDrawable = new RippleDrawable(new ColorStateList(new int[][] { new int[] { mStatePressed }, new int[] {} }, new int[] { mRippleColor != Integer.MAX_VALUE ? mRippleColor : getBackColor(mBackgroundPressedColor), mRippleColor }), getContentDrawable(mDrawable, isSetBg), null);
mView.setBackground(rippleDrawable);
} else {
if (!isSetBg) {
return;
}
setDrawable(mBackgroundPressed, mBackgroundPressedColor, mStrokePressedColor);
setDrawable(mBackgroundDisabled, mBackgroundDisabledColor, mStrokeDisabledColor);
StateListDrawable mStateDrawable = new StateListDrawable();
mStateDrawable.setEnterFadeDuration(mEnterFadeDuration);
mStateDrawable.setExitFadeDuration(mExitFadeDuration);
mStateDrawable.addState(new int[] { mStatePressed }, mBackgroundPressed);
mStateDrawable.addState(new int[] { mStateSelected }, mBackgroundSelected);
mStateDrawable.addState(new int[] { mStateChecked }, mBackgroundChecked);
mStateDrawable.addState(new int[] { mStateDisabled }, mBackgroundDisabled);
// 默认状态--放置在最后否则其它状态不生效
mStateDrawable.addState(new int[] {}, mBackground);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mView.setBackground(mStateDrawable);
} else {
mView.setBackgroundDrawable(mStateDrawable);
}
}
return;
}
use of android.graphics.drawable.RippleDrawable in project FloatingActionButton by hannesa2.
the class FloatingActionButton method createFillDrawable.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[] { -android.R.attr.state_enabled }, createCircleDrawable(mColorDisabled));
drawable.addState(new int[] { android.R.attr.state_pressed }, createCircleDrawable(mColorPressed));
drawable.addState(new int[] {}, createCircleDrawable(mColorNormal));
if (Util.hasLollipop()) {
RippleDrawable ripple = new RippleDrawable(new ColorStateList(new int[][] { {} }, new int[] { mColorRipple }), drawable, null);
setOutlineProvider(new ViewOutlineProvider() {
@Override
public void getOutline(View view, Outline outline) {
outline.setOval(0, 0, view.getWidth(), view.getHeight());
}
});
setClipToOutline(true);
mBackgroundDrawable = ripple;
return ripple;
}
mBackgroundDrawable = drawable;
return drawable;
}
Aggregations