/**
* Creates a vertical {@link LinearGradient}
* @return
*/
private Shader createGradientShader() {
final Rect rect = mRect;
copyBounds(rect);
final float borderRatio = mBorderWidth / rect.height();
final int[] colors = new int[6];
colors[0] = ColorUtils.compositeColors(mTopOuterStrokeColor, mCurrentBorderTintColor);
colors[1] = ColorUtils.compositeColors(mTopInnerStrokeColor, mCurrentBorderTintColor);
colors[2] = ColorUtils.compositeColors(
ColorUtils.setAlphaComponent(mTopInnerStrokeColor, 0), mCurrentBorderTintColor);
colors[3] = ColorUtils.compositeColors(
ColorUtils.setAlphaComponent(mBottomInnerStrokeColor, 0), mCurrentBorderTintColor);
colors[4] = ColorUtils.compositeColors(mBottomInnerStrokeColor, mCurrentBorderTintColor);
colors[5] = ColorUtils.compositeColors(mBottomOuterStrokeColor, mCurrentBorderTintColor);
final float[] positions = new float[6];
positions[0] = 0f;
positions[1] = borderRatio;
positions[2] = 0.5f;
positions[3] = 0.5f;
positions[4] = 1f - borderRatio;
positions[5] = 1f;
return new LinearGradient(
0, rect.top,
0, rect.bottom,
colors, positions,
Shader.TileMode.CLAMP);
}
CircularBorderDrawable.java 文件源码
java
阅读 25
收藏 0
点赞 0
评论 0
项目:cwac-crossport
作者:
评论列表
文章目录