本文整理汇总了Java中android.graphics.drawable.GradientDrawable.setGradientRadius方法的典型用法代码示例。如果您正苦于以下问题:Java GradientDrawable.setGradientRadius方法的具体用法?Java GradientDrawable.setGradientRadius怎么用?Java GradientDrawable.setGradientRadius使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.drawable.GradientDrawable
的用法示例。
在下文中一共展示了GradientDrawable.setGradientRadius方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCircleGradientDrawable
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
/**
* 创建一张渐变图片,支持圆角
*
* @param startColor 渐变开始色
* @param endColor 渐变结束色
* @param radius 圆角大小
* @param centerX 渐变中心点 X 轴坐标
* @param centerY 渐变中心点 Y 轴坐标
* @return
*/
@TargetApi(16)
public static GradientDrawable createCircleGradientDrawable(@ColorInt int startColor,
@ColorInt int endColor, int radius,
@FloatRange(from = 0f, to = 1f) float centerX,
@FloatRange(from = 0f, to = 1f) float centerY) {
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setColors(new int[]{
startColor,
endColor
});
gradientDrawable.setGradientType(GradientDrawable.RADIAL_GRADIENT);
gradientDrawable.setGradientRadius(radius);
gradientDrawable.setGradientCenter(centerX, centerY);
return gradientDrawable;
}
示例2: createCircleGradientDrawable
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
/**
* 创建一张渐变图片,支持韵脚。
*
* @param startColor 渐变开始色
* @param endColor 渐变结束色
* @param radius 圆角大小
* @param centerX 渐变中心点 X 轴坐标
* @param centerY 渐变中心点 Y 轴坐标
* @return 返回所创建的渐变图片。
*/
@TargetApi(16)
public static GradientDrawable createCircleGradientDrawable(@ColorInt int startColor,
@ColorInt int endColor, int radius,
@FloatRange(from = 0f, to = 1f) float centerX,
@FloatRange(from = 0f, to = 1f) float centerY) {
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setColors(new int[]{
startColor,
endColor
});
gradientDrawable.setGradientType(GradientDrawable.RADIAL_GRADIENT);
gradientDrawable.setGradientRadius(radius);
gradientDrawable.setGradientCenter(centerX, centerY);
return gradientDrawable;
}
示例3: initBackground
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void initBackground() {
GradientDrawable.Orientation orientation = getOrientation();
GradientDrawable drawable = new GradientDrawable(orientation, new int[]{bgGradientStart, bgGradientCenter, bgGradientEnd});
drawable.setShape(GradientDrawable.RECTANGLE);
drawable.setCornerRadius(dialogRadius);
switch (bgGradientType) {
case GRADIENT_RADIAL:
drawable.setGradientType(GradientDrawable.RADIAL_GRADIENT);
break;
case GRADIENT_SWEEP:
drawable.setGradientType(GradientDrawable.SWEEP_GRADIENT);
break;
default:
drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
break;
}
if (isHalloween) {
drawable.setGradientType(GradientDrawable.RADIAL_GRADIENT);
drawable.setGradientRadius(getContext().getResources().getDimensionPixelSize(R.dimen.dialog_height) / 2);
} else {
drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
root.setBackground(drawable);
} else {
root.setBackgroundDrawable(drawable);
}
}
示例4: setGradientRadius
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
void setGradientRadius(Context context, AttributeSet attrs, GradientDrawable drawable, int gradientType) throws XmlPullParserException {
TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{android.R.attr.gradientRadius});
TypedValue value = a.peekValue(0);
if (value != null) {
boolean radiusRel = value.type == TypedValue.TYPE_FRACTION;
drawable.setGradientRadius(radiusRel ? value.getFraction(1.0f, 1.0f) : value.getFloat());
} else if (gradientType == GradientDrawable.RADIAL_GRADIENT) {
throw new XmlPullParserException(
"<gradient> tag requires 'gradientRadius' "
+ "attribute with radial type");
}
a.recycle();
}
示例5: drawBackground
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
private void drawBackground(View v, int color, boolean isCircle) {
if (isCircle) {
GradientDrawable gd = new GradientDrawable();
gd.setGradientType(GradientDrawable.RADIAL_GRADIENT);
gd.setColors(new int[]{color, Color.TRANSPARENT });
gd.setGradientRadius((Defaults.IMAGE_HEIGHT - Defaults.CIRCLE_PADDING)/2);
v.setBackground(gd);
} else {
ShapeDrawable oval = new ShapeDrawable (new OvalShape());
oval.getPaint().setColor(color);
v.setBackground(oval);
}
}
示例6: create
import android.graphics.drawable.GradientDrawable; //导入方法依赖的package包/类
public static GradientDrawable create(@ColorInt int startColor, @ColorInt int endColor, int radius,
@FloatRange(from = 0f, to = 1f) float centerX,
@FloatRange(from = 0f, to = 1f) float centerY) {
GradientDrawable gradientDrawable = new GradientDrawable();
gradientDrawable.setColors(new int[]{
startColor,
endColor
});
gradientDrawable.setGradientType(GradientDrawable.RADIAL_GRADIENT);
gradientDrawable.setGradientRadius(radius);
gradientDrawable.setGradientCenter(centerX, centerY);
return gradientDrawable;
}