Last active
August 21, 2018 10:18
-
-
Save SouravKumarPandit/1dee412d20210375f7e495bce8ebb9ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LinearLayout2D extends LinearLayout { | |
Paint rectPaint; | |
int intShaderType=0; | |
public LinearLayout2D(Context context) | |
{ | |
super(context); | |
init(context); | |
} | |
private void init(Context context) | |
{ | |
rectPaint = new Paint(); | |
// rectPaint.setDither(true); | |
rectPaint.setStyle(Paint.Style.FILL); | |
rectPaint.setStrokeJoin(Paint.Join.ROUND); | |
rectPaint.setStrokeCap(Paint.Cap.ROUND); | |
rectPaint.setAntiAlias(true); | |
// setGradient(0xfff9f9f9, 0xffc6c6c6); | |
} | |
public LinearLayout2D(Context context, @Nullable AttributeSet attrs) | |
{ | |
super(context, attrs); | |
init(context); | |
} | |
public LinearLayout2D(Context context, @Nullable AttributeSet attrs, int defStyleAttr) | |
{ | |
super(context, attrs, defStyleAttr); | |
init(context); | |
} | |
@Override | |
protected void dispatchDraw(Canvas canvas) | |
{ | |
// setBackgroundColor(Color.GREEN); | |
// setGradient(Color.parseColor("#f5f5f5"), Color.parseColor("#e4e4e4")); | |
// setGradient(Color.parseColor("#ececec"),Color.parseColor("#fdfdfd")); | |
// setGradient(0xfff2edef,0xffd6cbcf); | |
setGradient(0xffffffff,0xffd6d6d6); | |
canvas.drawRect(0, 0, getWidth(), getHeight(), rectPaint); | |
super.dispatchDraw(canvas); | |
} | |
public void setGradient(int sColor, int eColor) | |
{ | |
rectPaint.setShader(new LinearGradient(0, 0, 0, getHeight() / 2, | |
new int[]{sColor, eColor}, | |
new float[]{0.0f, 1.0f}, Shader.TileMode.CLAMP)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment