本文整理汇总了Java中android.graphics.drawable.ShapeDrawable.ShaderFactory方法的典型用法代码示例。如果您正苦于以下问题:Java ShapeDrawable.ShaderFactory方法的具体用法?Java ShapeDrawable.ShaderFactory怎么用?Java ShapeDrawable.ShaderFactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.drawable.ShapeDrawable
的用法示例。
在下文中一共展示了ShapeDrawable.ShaderFactory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawable
import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
public static Drawable drawable(final int[] colorBoxes, final float[] position, final GradientAngle gradientAngle) {
ShapeDrawable.ShaderFactory shaderFactory = new ShapeDrawable.ShaderFactory() {
@Override
public Shader resize(int width, int height) {
AngleCoordinate ac = AngleCoordinate.getAngleCoordinate(gradientAngle, width, height);
LinearGradient linearGradient = new LinearGradient(ac.x1, ac.y1, ac.x2, ac.y2,
colorBoxes,
position,
Shader.TileMode.REPEAT);
return linearGradient;
}
};
PaintDrawable paint = new PaintDrawable();
paint.setShape(new RectShape());
paint.setShaderFactory(shaderFactory);
return paint;
}
示例2: getShaderFactory
import android.graphics.drawable.ShapeDrawable; //导入方法依赖的package包/类
private static ShapeDrawable.ShaderFactory getShaderFactory(final int startX, final int endX) {
return new ShapeDrawable.ShaderFactory() {
@Override
public Shader resize(int width, int height) {
return new LinearGradient(startX, 0, endX, 0,
new int[]{0xFFDCDAD5, 0xFFFDFDF4,
0xFFFFFFFF, 0xFFFDFBEF},
new float[]{0, 0.18f, 0.48f, 1},
Shader.TileMode.REPEAT);
}
};
}