当前位置: 首页>>代码示例>>Java>>正文


Java RippleDrawable类代码示例

本文整理汇总了Java中android.graphics.drawable.RippleDrawable的典型用法代码示例。如果您正苦于以下问题:Java RippleDrawable类的具体用法?Java RippleDrawable怎么用?Java RippleDrawable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RippleDrawable类属于android.graphics.drawable包,在下文中一共展示了RippleDrawable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateRippleDrawable

import android.graphics.drawable.RippleDrawable; //导入依赖的package包/类
@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;
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:DayView.java

示例2: update

import android.graphics.drawable.RippleDrawable; //导入依赖的package包/类
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);
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:CircleView.java

示例3: setDiscrete

import android.graphics.drawable.RippleDrawable; //导入依赖的package包/类
/**
 * 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();
	}
}
 
开发者ID:universum-studios,项目名称:android_ui,代码行数:34,代码来源:SeekBarWidget.java

示例4: setupForeground

import android.graphics.drawable.RippleDrawable; //导入依赖的package包/类
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);
    }
}
 
开发者ID:alibaba,项目名称:LuaViewPlayground,代码行数:18,代码来源:ForegroundDelegate.java

示例5: showStopwatchRipple

import android.graphics.drawable.RippleDrawable; //导入依赖的package包/类
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[] {  });
            }
        }
    });
}
 
开发者ID:kingblaubart,项目名称:quidditchtimekeeper,代码行数:18,代码来源:GameActivity.java

示例6: createBackgroundDrawable

import android.graphics.drawable.RippleDrawable; //导入依赖的package包/类
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;
    }
}
 
开发者ID:bartbergmans,项目名称:GradientButton,代码行数:19,代码来源:GradientButton.java

示例7: createFillDrawable

import android.graphics.drawable.RippleDrawable; //导入依赖的package包/类
@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;
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:25,代码来源:FloatingActionButton.java

示例8: createFillDrawable

import android.graphics.drawable.RippleDrawable; //导入依赖的package包/类
@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[][]{{}},
                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;
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:24,代码来源:Label.java

示例9: onActionDown

import android.graphics.drawable.RippleDrawable; //导入依赖的package包/类
@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);
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:18,代码来源:Label.java

示例10: onActionUp

import android.graphics.drawable.RippleDrawable; //导入依赖的package包/类
@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, getMeasuredHeight() / 2);
        ripple.setVisible(true, true);
    }
    setPressed(false);
}
 
开发者ID:WeiMei-Tian,项目名称:editor-sql,代码行数:18,代码来源:Label.java

示例11: onActionDown

import android.graphics.drawable.RippleDrawable; //导入依赖的package包/类
@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);
    }
 
开发者ID:Blankeer,项目名称:MDWechat,代码行数:18,代码来源:Label.java

示例12: onActionUp

import android.graphics.drawable.RippleDrawable; //导入依赖的package包/类
@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, getMeasuredHeight() / 2);
            ripple.setVisible(true, true);
        }
//        setPressed(false);
    }
 
开发者ID:Blankeer,项目名称:MDWechat,代码行数:18,代码来源:Label.java

示例13: createRippleDrawable

import android.graphics.drawable.RippleDrawable; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:milosmns,项目名称:silly-android,代码行数:35,代码来源:Coloring.java

示例14: onActionUp

import android.graphics.drawable.RippleDrawable; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:13,代码来源:FloatingActionButton.java

示例15: createBtnAndSetFunc

import android.graphics.drawable.RippleDrawable; //导入依赖的package包/类
/**
 * 创建按钮并且设置对应功能
 *
 * @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, null);
    btn.setBackground(ripple);
    btn.setScaleType(ImageView.ScaleType.CENTER);
    btn.setOnClickListener(getBtnFuncOfName(sc));
    btn.setOnLongClickListener(getBtnLongFuncOfName(sc.getCode()));

    line.addView(btn, p);
}
 
开发者ID:EggUncle,项目名称:XposedNavigationBar,代码行数:37,代码来源:BtnFuncFactory.java


注:本文中的android.graphics.drawable.RippleDrawable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。