當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。