Skip to content

Instantly share code, notes, and snippets.

@armanso
Last active February 16, 2020 20:00
Show Gist options
  • Save armanso/6633bef3ecba3aee226ec2dc1d6e4365 to your computer and use it in GitHub Desktop.
Save armanso/6633bef3ecba3aee226ec2dc1d6e4365 to your computer and use it in GitHub Desktop.
class TestFrameLayout @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
) : FrameLayout(context, attrs, defStyleAttr) {
private val paint: Paint = Paint()
init {
clipChildren = false
clipToPadding = false
paint.color = Color.WHITE
// change this number to match your expertise.
paint.setShadowLayer(
10f, 0f, 10f,
ContextCompat.getColor(context, R.color.shadow)
)
paint.xfermode = PorterDuffXfermode(PorterDuff.Mode.ADD)
setShadow(R.color.shadow, R.dimen.radius, R.dimen.evl, backgroundColorResource = R.color.bg)
setLayerType(LAYER_TYPE_SOFTWARE, null)
}
override fun onDraw(canvas: Canvas?) {
super.onDraw(canvas)
canvas?.run {
save()
translate((canvas.width / 2).toFloat(), CIRCLE_RD)
drawCircle(0f, 0f, CIRCLE_RD, paint)
restore()
}
}
companion object {
const val CIRCLE_RD = 100f
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment