Skip to content

Commit

Permalink
Adjust badge layout (#4771)
Browse files Browse the repository at this point in the history
  • Loading branch information
SeniorZhai authored Jul 4, 2024
1 parent 9cc7960 commit e2e1097
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ open class BadgeCircleImageView(context: Context, attrs: AttributeSet?) :

var pos: Int = START_BOTTOM

init {
clipToPadding = false
}

override fun onMeasure(
widthMeasureSpec: Int,
heightMeasureSpec: Int,
Expand All @@ -47,11 +43,12 @@ open class BadgeCircleImageView(context: Context, attrs: AttributeSet?) :
val badgeWidth = measuredWidth / 3
if (pos == START_BOTTOM) {
val positionLeft = (measuredWidth * 0.011f).toInt()
val positionTop = (measuredWidth * 0.7f).toInt()
val positionTop = (measuredHeight - badgeWidth)
binding.badge.layout(positionLeft, positionTop, positionLeft + badgeWidth, positionTop + badgeWidth)
} else if (pos == END_BOTTOM) {
val position = (measuredWidth * 0.7f).toInt()
binding.badge.layout(position, position, position + badgeWidth, position + badgeWidth)
val positionLeft = (measuredWidth - badgeWidth)
val positionTop = (measuredHeight - badgeWidth)
binding.badge.layout(positionLeft, positionTop, positionLeft + badgeWidth, positionTop + badgeWidth)
}
}

Expand Down

0 comments on commit e2e1097

Please sign in to comment.