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


Java RippleDrawable.setBounds方法代码示例

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


在下文中一共展示了RippleDrawable.setBounds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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:Pattonville-App-Development-Team,项目名称:Android-App,代码行数:19,代码来源:CalendarDecoratorUtil.java


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