项目:GitHub
文件:DayView.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static Drawable generaterippledrawable(final int color,Rect bounds) {
ColorStateList list = ColorStateList.valueOf(color);
Drawable mask = generateCircleDrawable(Color.WHITE);
rippledrawable rippledrawable = new rippledrawable(list,null,mask);
// API 21
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) {
rippledrawable.setBounds(bounds);
}
// API 22. Technically harmless to leave on for API 21 and 23,but not worth risking for 23+
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP_MR1) {
int center = (bounds.left + bounds.right) / 2;
rippledrawable.setHotspotBounds(center,bounds.top,center,bounds.bottom);
}
return rippledrawable;
}
项目:GitHub
文件:CircleView.java
private void update(@ColorInt int color) {
innerPaint.setColor(color);
outerPaint.setColor(shiftColorDown(color));
Drawable selector = createSelector(color);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int[][] states = new int[][]{
new int[]{android.R.attr.state_pressed}
};
int[] colors = new int[]{shiftColorUp(color)};
ColorStateList rippleColors = new ColorStateList(states,colors);
setForeground(new rippledrawable(rippleColors,selector,null));
} else {
setForeground(selector);
}
}
项目:android_ui
文件:SeekBarWidget.java
/**
* Sets a flag indicating whether this seek bar is <b>discrete</b> or not.
* <p>
* SeekBarWidget in the discrete mode draws,above the progress track and the thumb,a discrete
* indicator to show to a user current progress value. discrete indicator's drawable can be set
* via {@link #setdiscreteIndicator(android.graphics.drawable.Drawable)}.
*
* @param discrete {@code True} to enable discrete mode,{@code false} otherwise.
* @see R.attr#uidiscrete ui:uidiscrete
* @see #isdiscrete()
*/
public void setdiscrete(boolean discrete) {
if (discrete && UiConfig.MATERIALIZED) {
final Drawable background = getBackground();
if (background instanceof rippledrawable) {
// This is a little bit harsh,but the rippledrawable background is showing a ripple
// in discrete mode in top left corner of this view's bounds which is kind of weird
// behavIoUr.
this.mRippleBackgroundDrawable = background;
setBackgroundDrawable(null);
}
} else if (!discrete && mRippleBackgroundDrawable != null) {
setBackgroundDrawable(mRippleBackgroundDrawable);
this.mRippleBackgroundDrawable = null;
}
this.ensureDecorator();
if (mDecorator.hasPrivateFlag(PFLAG_disCRETE) != discrete) {
mDecorator.updatePrivateFlags(PFLAG_disCRETE,discrete);
this.updateThumb(mThumb);
this.updatediscreteIndicator(mdiscreteIndicator);
requestLayout();
}
}
项目:LuaViewPlayground
文件:ForegroundDelegate.java
private static void setupForeground(View view,Drawable drawable,Integer color,Integer alpha) {
if (view instanceof IForeground) {
if (color != null) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
if (drawable instanceof rippledrawable) {
rippledrawable rippledrawable = (rippledrawable) drawable;
rippledrawable.setColor(ColorStateList.valueOf(color));
if (alpha != null) {
rippledrawable.setAlpha(alpha);
}
}
}
}
((IForeground) view).setForeground(drawable);
}
}
项目:quidditchtimekeeper
文件:GameActivity.java
public void showStopwatchRipple()
{
new Handler(Looper.getMainLooper()).post(new Runnable()
{
@Override
public void run()
{
View stopwatchView = findViewById(R.id.stopwatch);
if(stopwatchView!=null)
{
rippledrawable rd = (rippledrawable) stopwatchView.getBackground();
rd.setState(new int[] { android.R.attr.state_pressed,android.R.attr.state_enabled });
rd.setState(new int[] { });
}
}
});
}
项目:GradientButton
文件:GradientButton.java
private Drawable createBackgroundDrawable(int width,int height) {
if (isCircular && height > width) {
width = height;
} else if (isCircular && width > height) {
height = width;
}
Drawable content = createContentDrawable(width,height);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Log.d(TAG,"RIPPLE APPLIED,with color: " + mRippleColor);
Drawable mask = createMaskDrawable(width,height);
ColorStateList stateList = ColorStateList.valueOf(mRippleColor);
return new rippledrawable(stateList,content,mask);
} else {
return content;
}
}
@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,view.getWidth(),view.getHeight());
}
});
setClipToOutline(true);
mBackgroundDrawable = ripple;
return ripple;
}
mBackgroundDrawable = drawable;
return drawable;
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[]{android.R.attr.state_pressed},createRectDrawable(mColorpressed));
drawable.addState(new int[]{},createRectDrawable(mColornormal));
if (Util.hasLollipop()) {
rippledrawable ripple = new rippledrawable(new ColorStateList(new int[][]{{}},view.getHeight());
}
});
setClipToOutline(true);
mBackgroundDrawable = ripple;
return ripple;
}
mBackgroundDrawable = drawable;
return drawable;
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionDown() {
if (mUsingStyle) {
mBackgroundDrawable = getBackground();
}
if (mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[]{android.R.attr.state_pressed});
} else if (Util.hasLollipop() && mBackgroundDrawable instanceof rippledrawable) {
rippledrawable ripple = (rippledrawable) mBackgroundDrawable;
ripple.setState(new int[]{android.R.attr.state_enabled,android.R.attr.state_pressed});
ripple.setHotspot(getMeasuredWidth() / 2,getMeasuredHeight() / 2);
ripple.setVisible(true,true);
}
setpressed(true);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionUp() {
if (mUsingStyle) {
mBackgroundDrawable = getBackground();
}
if (mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[]{});
} else if (Util.hasLollipop() && mBackgroundDrawable instanceof rippledrawable) {
rippledrawable ripple = (rippledrawable) mBackgroundDrawable;
ripple.setState(new int[]{});
ripple.setHotspot(getMeasuredWidth() / 2,true);
}
setpressed(false);
}
项目:MDWechat
文件:FloatingActionButton.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[]{-android.R.attr.state_enabled},view.getHeight());
}
});
setClipToOutline(true);
mBackgroundDrawable = ripple;
return ripple;
}
mBackgroundDrawable = drawable;
return drawable;
}
项目:MDWechat
文件:Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[]{android.R.attr.state_pressed},view.getHeight());
}
});
setClipToOutline(true);
mBackgroundDrawable = ripple;
return ripple;
}
mBackgroundDrawable = drawable;
return drawable;
}
项目:MDWechat
文件:Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionDown() {
if (mUsingStyle) {
mBackgroundDrawable = getBackground();
}
if (mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[]{android.R.attr.state_pressed});
} else if (Util.hasLollipop() && mBackgroundDrawable instanceof rippledrawable) {
rippledrawable ripple = (rippledrawable) mBackgroundDrawable;
ripple.setState(new int[]{android.R.attr.state_enabled,android.R.attr.state_pressed});
ripple.setHotspot(getMeasuredWidth() / 2,getMeasuredHeight() / 2);
ripple.setVisible(true,true);
}
// setpressed(true);
}
项目:MDWechat
文件:Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionUp() {
if (mUsingStyle) {
mBackgroundDrawable = getBackground();
}
if (mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[]{});
} else if (Util.hasLollipop() && mBackgroundDrawable instanceof rippledrawable) {
rippledrawable ripple = (rippledrawable) mBackgroundDrawable;
ripple.setState(new int[]{});
ripple.setHotspot(getMeasuredWidth() / 2,true);
}
// setpressed(false);
}
项目:silly-android
文件:Coloring.java
/**
* Creates a new {@link rippledrawable} introduced in Lollipop.
*
* @param normalColor Color for the idle/normal state
* @param rippleColor Color for the ripple effect
* @param bounds Clipping bounds for the ripple state. Set to {@code null} to get a borderless ripple
* @param cornerRadius Set to round the corners on rectangular drawables,0 to disable
* @return A fully colored rippledrawable,new instance each time
*/
@NonNull
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
public static rippledrawable createrippledrawable(@ColorInt final int normalColor,@ColorInt final int rippleColor,@Nullable final Rect bounds,@IntRange(from = 0) final int cornerRadius) {
Drawable maskDrawable = null;
if (bounds != null) {
// clip color is white
maskDrawable = createColoredDrawable(Color.WHITE,bounds);
if (maskDrawable instanceof GradientDrawable) {
((GradientDrawable) maskDrawable).setCornerRadius(cornerRadius);
}
maskDrawable.setBounds(bounds);
}
Drawable normalStateDrawable = null;
// transparent has no idle state
if (normalColor != Color.TRANSPARENT) {
normalStateDrawable = createColoredDrawable(normalColor,bounds);
if (normalStateDrawable instanceof GradientDrawable) {
((GradientDrawable) normalStateDrawable).setCornerRadius(cornerRadius);
}
}
return new rippledrawable(ColorStateList.valueOf(rippleColor),normalStateDrawable,maskDrawable);
}
项目:ChatExchange-old
文件:FloatingActionButton.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[]{-android.R.attr.state_enabled},view.getHeight());
}
});
setClipToOutline(true);
mBackgroundDrawable = ripple;
return ripple;
}
mBackgroundDrawable = drawable;
return drawable;
}
项目:ChatExchange-old
文件:Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[]{android.R.attr.state_pressed},view.getHeight());
}
});
setClipToOutline(true);
mBackgroundDrawable = ripple;
return ripple;
}
mBackgroundDrawable = drawable;
return drawable;
}
项目:ChatExchange-old
文件:Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionDown() {
if (mUsingStyle) {
mBackgroundDrawable = getBackground();
}
if (mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[]{android.R.attr.state_pressed});
} else if (Util.hasLollipop() && mBackgroundDrawable instanceof rippledrawable) {
rippledrawable ripple = (rippledrawable) mBackgroundDrawable;
ripple.setState(new int[]{android.R.attr.state_enabled,true);
}
// setpressed(true);
}
项目:ChatExchange-old
文件:Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionUp() {
if (mUsingStyle) {
mBackgroundDrawable = getBackground();
}
if (mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[]{});
} else if (Util.hasLollipop() && mBackgroundDrawable instanceof rippledrawable) {
rippledrawable ripple = (rippledrawable) mBackgroundDrawable;
ripple.setState(new int[]{});
ripple.setHotspot(getMeasuredWidth() / 2,true);
}
// setpressed(false);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[]{-android.R.attr.state_enabled},view.getHeight());
}
});
setClipToOutline(true);
mBackgroundDrawable = ripple;
return ripple;
}
mBackgroundDrawable = drawable;
return drawable;
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[]{android.R.attr.state_pressed},view.getHeight());
}
});
setClipToOutline(true);
mBackgroundDrawable = ripple;
return ripple;
}
mBackgroundDrawable = drawable;
return drawable;
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionDown() {
if (mUsingStyle) {
mBackgroundDrawable = getBackground();
}
if (mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[]{android.R.attr.state_pressed});
} else if (Util.hasLollipop() && mBackgroundDrawable instanceof rippledrawable) {
rippledrawable ripple = (rippledrawable) mBackgroundDrawable;
ripple.setState(new int[]{android.R.attr.state_enabled,true);
}
// setpressed(true);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionUp() {
if (mUsingStyle) {
mBackgroundDrawable = getBackground();
}
if (mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[]{});
} else if (Util.hasLollipop() && mBackgroundDrawable instanceof rippledrawable) {
rippledrawable ripple = (rippledrawable) mBackgroundDrawable;
ripple.setState(new int[]{});
ripple.setHotspot(getMeasuredWidth() / 2,true);
}
// setpressed(false);
}
/**
* 创建按钮并且设置对应功能
*
* @param line
* @param sc
*/
public void createBtnAndSetFunc(LinearLayout line,ShortCut sc) {
int iconScale = DataHook.iconScale;
LinearLayout.LayoutParams p = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);
p.weight = 1;
p.gravity = Gravity.CENTER;
Context context = line.getContext();
ImageView btn = new ImageView(context);
String iconPath = sc.getIconPath();
Bitmap iconBitmap = null;
if (iconPath != null) {
iconBitmap = ImageUtil.zoomBitmap(iconPath,iconScale);
}
if (iconBitmap == null) {
iconBitmap = ImageUtil.byte2Bitmap(mMapImgRes.get(sc.getCode()));
iconBitmap = ImageUtil.zommBitmap(iconBitmap,iconScale);
}
btn.setimageBitmap(iconBitmap);
ColorStateList colorStateList = createColorStateList(0xffffffff,0xffffff00,0xff0000ff,0xffff0000);
rippledrawable ripple = new rippledrawable(colorStateList,null);
btn.setBackground(ripple);
btn.setScaleType(ImageView.ScaleType.CENTER);
btn.setonClickListener(getBtnFuncOfName(sc));
btn.setonLongClickListener(getBtnLongFuncOfName(sc.getCode()));
line.addView(btn,p);
}
项目:calendarview2
文件:DayView.java
项目:MaterialFBook
文件:FloatingActionButton.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[]{-android.R.attr.state_enabled},view.getHeight());
}
});
setClipToOutline(true);
mBackgroundDrawable = ripple;
return ripple;
}
mBackgroundDrawable = drawable;
return drawable;
}
项目:MaterialFBook
文件:Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[]{android.R.attr.state_pressed},view.getHeight());
}
});
setClipToOutline(true);
mBackgroundDrawable = ripple;
return ripple;
}
mBackgroundDrawable = drawable;
return drawable;
}
项目:MaterialFBook
文件:Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionDown() {
if (mUsingStyle) {
mBackgroundDrawable = getBackground();
}
if (mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[]{android.R.attr.state_pressed});
} else if (Util.hasLollipop() && mBackgroundDrawable instanceof rippledrawable) {
rippledrawable ripple = (rippledrawable) mBackgroundDrawable;
ripple.setState(new int[]{android.R.attr.state_enabled,true);
}
}
项目:MaterialFBook
文件:Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionUp() {
if (mUsingStyle) {
mBackgroundDrawable = getBackground();
}
if (mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[]{});
} else if (Util.hasLollipop() && mBackgroundDrawable instanceof rippledrawable) {
rippledrawable ripple = (rippledrawable) mBackgroundDrawable;
ripple.setState(new int[]{});
ripple.setHotspot(getMeasuredWidth() / 2,true);
}
}
项目:FloatingActionButtonEx
文件:FloatingActionButton.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[]{-android.R.attr.state_enabled},createCircleDrawable(mColornormal));
if (!isInEditMode() && Util.hasLollipop()) {
rippledrawable ripple = new rippledrawable(new ColorStateList(new int[][]{{}},view.getHeight());
}
});
setClipToOutline(true);
mBackgroundDrawable = ripple;
return ripple;
}
mBackgroundDrawable = drawable;
return drawable;
}
项目:FloatingActionButtonEx
文件:Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[]{android.R.attr.state_pressed},view.getHeight());
}
});
setClipToOutline(true);
mBackgroundDrawable = ripple;
return ripple;
}
mBackgroundDrawable = drawable;
return drawable;
}
项目:FloatingActionButtonEx
文件:Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionDown() {
if (mUsingStyle) {
mBackgroundDrawable = getBackground();
}
if (mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[]{android.R.attr.state_pressed});
} else if (Util.hasLollipop() && mBackgroundDrawable instanceof rippledrawable) {
rippledrawable ripple = (rippledrawable) mBackgroundDrawable;
ripple.setState(new int[]{android.R.attr.state_enabled,true);
}
setpressed(true);
}
项目:FloatingActionButtonEx
文件:Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionUp() {
if (mUsingStyle) {
mBackgroundDrawable = getBackground();
}
if (mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[]{});
} else if (Util.hasLollipop() && mBackgroundDrawable instanceof rippledrawable) {
rippledrawable ripple = (rippledrawable) mBackgroundDrawable;
ripple.setState(new int[]{});
ripple.setHotspot(getMeasuredWidth() / 2,true);
}
setpressed(false);
}
项目:talk-android
文件:CircleView.java
@SuppressLint("NewApi")
private void update(@ColorInt int color) {
innerPaint.setColor(color);
outerPaint.setColor(shiftColorDown(color));
Drawable selector = createSelector(color);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int[][] states = new int[][]{
new int[]{android.R.attr.state_pressed}
};
int[] colors = new int[]{shiftColorUp(color)};
ColorStateList rippleColors = new ColorStateList(states,null));
} else {
setForeground(selector);
}
}
项目:permissionsModule
文件:FloatingActionButtonLollipop.java
@Override
void setBackgroundDrawable(ColorStateList backgroundTint,PorterDuff.Mode backgroundTintMode,int rippleColor,int borderWidth) {
// Now we need to tint the shape background with the tint
mShapeDrawable = DrawableCompat.wrap(createShapeDrawable());
DrawableCompat.setTintList(mShapeDrawable,backgroundTint);
if (backgroundTintMode != null) {
DrawableCompat.setTintMode(mShapeDrawable,backgroundTintMode);
}
final Drawable rippleContent;
if (borderWidth > 0) {
mBorderDrawable = createBorderDrawable(borderWidth,backgroundTint);
rippleContent = new LayerDrawable(new Drawable[]{mBorderDrawable,mShapeDrawable});
} else {
mBorderDrawable = null;
rippleContent = mShapeDrawable;
}
mrippledrawable = new rippledrawable(ColorStateList.valueOf(rippleColor),rippleContent,null);
mContentBackground = mrippledrawable;
mShadowViewDelegate.setBackgroundDrawable(mrippledrawable);
}
项目:android_packages_apps_tv
文件:SideFragment.java
@Override
public void onClick(View view) {
if (mItem instanceof RadioButtonItem) {
mAdapter.clearRadioGroup(mItem);
}
if (view.getBackground() instanceof rippledrawable) {
view.postDelayed(new Runnable() {
@Override
public void run() {
if (mItem != null) {
mItem.onSelected();
}
}
},view.getResources().getInteger(R.integer.side_panel_ripple_anim_duration));
} else {
mItem.onSelected();
}
}
项目:AndroidProjectsClient
文件:Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Drawable createFillDrawable() {
StateListDrawable drawable = new StateListDrawable();
drawable.addState(new int[] {android.R.attr.state_pressed},createRectDrawable(mColorpressed)
);
drawable.addState(new int[] {},createRectDrawable(mColornormal));
if(Util.hasLollipop() && mUsingripple) {
rippledrawable ripple = new rippledrawable(new ColorStateList(new int[][] {{}},new int[] {mColorRipple}
),view.getHeight());
}
});
setClipToOutline(true);
mBackgroundDrawable = ripple;
return ripple;
}
mBackgroundDrawable = drawable;
return drawable;
}
项目:AndroidProjectsClient
文件:Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionDown() {
if(mUsingStyle) {
mBackgroundDrawable = getBackground();
}
if(mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[] {android.R.attr.state_pressed});
} else if(Util.hasLollipop() && mBackgroundDrawable instanceof rippledrawable) {
rippledrawable ripple = (rippledrawable) mBackgroundDrawable;
ripple.setState(new int[] {android.R.attr.state_enabled,true);
}
// setpressed(true);
}
项目:AndroidProjectsClient
文件:Label.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionUp() {
if(mUsingStyle) {
mBackgroundDrawable = getBackground();
}
if(mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[] {});
} else if(Util.hasLollipop() && mBackgroundDrawable instanceof rippledrawable) {
rippledrawable ripple = (rippledrawable) mBackgroundDrawable;
ripple.setState(new int[] {});
ripple.setHotspot(getMeasuredWidth() / 2,true);
}
// setpressed(false);
}
项目:Slice
文件:Slice.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setRipple(final int mask) {
if (SDK_LOLLIPOP) {
if (mask != 0) {
ShapeDrawable shape = new ShapeDrawable(new Shape() {
@Override
public void draw(Canvas canvas,Paint paint) {
paint.setColor(mask);
canvas.drawPath(((CustomroundRectDrawable) drawable).buildConvexPath(),paint);
}
});
rippledrawable ripple = new rippledrawable(buildColorStateList(mask),shape);
view.setBackground(ripple);
} else {
view.setBackground(drawable);
}
} else {
Log.i(TAG,"setRipple() only work for API 21+");
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。