本文整理匯總了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);
}
};
}