This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.constraintlayout.widget.ConstraintLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:id="@+id/constraint_layout" | |
android:background="?android:attr/colorBackground" | |
tools:context=".ui.login.LoginActivity" |
This file contains hidden or 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
override fun onDraw(canvas: Canvas?) { | |
super.onDraw(canvas) | |
try { | |
... | |
borderPath.set(path) | |
path.lineTo(width.toFloat(), height.toFloat()) | |
path.lineTo(0f, height.toFloat()) | |
canvas?.drawPath(path, pathPaint) | |
canvas?.drawPath(borderPath, borderPathPaint) | |
} catch (e: Exception) { |
This file contains hidden or 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
pathPaint.apply { | |
isAntiAlias = true | |
style = Paint.Style.FILL | |
color = fillColor | |
} |
This file contains hidden or 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
borderPathPaint.apply { | |
isAntiAlias = true | |
strokeWidth = 8f | |
style = Paint.Style.STROKE | |
color = Color.parseColor("#FFFC4F47") | |
} |
This file contains hidden or 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
private fun drawBezierCurve(canvas: Canvas?) { | |
try { | |
if (points.isEmpty() && conPoint1.isEmpty() && conPoint2.isEmpty()) return | |
path.reset() | |
path.moveTo(points.first().x, points.first().y) | |
for (i in 1 until points.size) { |
This file contains hidden or 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
private fun calculateConnectionPointsForBezierCurve() { | |
try { | |
for (i in 1 until points.size) { | |
conPoint1.add(PointF((points[i].x + points[i - 1].x) / 2, points[i - 1].y)) | |
conPoint2.add(PointF((points[i].x + points[i - 1].x) / 2, points[i].y)) | |
} | |
} catch (e: Exception) { | |
} | |
} |
This file contains hidden or 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
//Sample Data points -> 50,25,100,80,...(your data to be represented in graph) | |
private fun calculatePointsForData() { | |
val bottomY = getLargeBarHeight() - CURVE_BOTTOM_MARGIN | |
val xDiff = width.toFloat() / data.size | |
val maxData = data.maxBy { it.amount }!!.amount | |
for (i in 0 until data.size) { | |
val y = bottomY - (data[i].amount / maxData * bottomY) |