本文整理匯總了Java中android.graphics.drawable.RippleDrawable.getDrawable方法的典型用法代碼示例。如果您正苦於以下問題:Java RippleDrawable.getDrawable方法的具體用法?Java RippleDrawable.getDrawable怎麽用?Java RippleDrawable.getDrawable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.graphics.drawable.RippleDrawable
的用法示例。
在下文中一共展示了RippleDrawable.getDrawable方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRippleShapeDrawable
import android.graphics.drawable.RippleDrawable; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static GradientDrawable getRippleShapeDrawable(Drawable background) {
if (!(background instanceof RippleDrawable))
return null;
RippleDrawable ripple = (RippleDrawable)background;
Drawable possibleInset = ripple.getDrawable(0);
if (!(possibleInset instanceof InsetDrawable))
return null;
InsetDrawable inset = (InsetDrawable)possibleInset;
Drawable possibleGradient = inset.getDrawable();
if (!(possibleGradient instanceof GradientDrawable))
return null;
// Mutate the drawable, otherwise the color will be set for all instances
possibleGradient = possibleGradient.mutate();
return (GradientDrawable)possibleGradient;
}
示例2: colorButton
import android.graphics.drawable.RippleDrawable; //導入方法依賴的package包/類
@Override
public void colorButton(int id, int bgColor, int tintColor) {
View buttonView = findViewById(id);
RippleDrawable ripple = (RippleDrawable) buttonView.getBackground();
GradientDrawable rippleBackground = (GradientDrawable) ripple.getDrawable(0);
rippleBackground.setColor(bgColor);
ripple.setColor(ColorStateList.valueOf(tintColor));
}
示例3: colorRipple
import android.graphics.drawable.RippleDrawable; //導入方法依賴的package包/類
private void colorRipple(int id, int bgColor, int tintColor) {
View buttonView = findViewById(id);
RippleDrawable ripple = (RippleDrawable) buttonView.getBackground();
GradientDrawable rippleBackground = (GradientDrawable) ripple.getDrawable(0);
rippleBackground.setColor(bgColor);
ripple.setColor(ColorStateList.valueOf(tintColor));
}