Skip to content

Instantly share code, notes, and snippets.

@2hamed
Created January 1, 2019 11:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 2hamed/e3b5d5ff975bd95ec5163b621eef17d2 to your computer and use it in GitHub Desktop.
Save 2hamed/e3b5d5ff975bd95ec5163b621eef17d2 to your computer and use it in GitHub Desktop.
private var cx: Float = 0f // x coordinate of the center
private var cy: Float = 0f // y coordinate of the center
private var radius: Float = 0f // the radius of the view = min(width, height) * 0.95
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
if (measuredHeight > 0 && measuredWidth > 0) {
cx = measuredWidth / 2f
cy = measuredHeight / 2f
radius = Math.min(measuredHeight, measuredWidth) / 2 * 0.95f - paddingBottom
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment