feat(banner): 배너 wrap content 높이를 지원한다

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-05-28 11:14:02 +09:00
parent dcc76abf94
commit 49984cb651
2 changed files with 47 additions and 0 deletions

View File

@@ -74,6 +74,21 @@ class BannerView @JvmOverloads constructor(
super.onDetachedFromWindow()
}
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
val widthSize = MeasureSpec.getSize(widthMeasureSpec)
val heightMode = MeasureSpec.getMode(heightMeasureSpec)
val measuredHeightSpec = if (widthSize > 0 && heightMode != MeasureSpec.EXACTLY) {
val density = resources.displayMetrics.density
val screenWidthDp = (widthSize / density).roundToInt()
val desiredHeight = BannerLayoutCalculator.calculate(screenWidthDp, density).itemHeightDp.dpToPx()
MeasureSpec.makeMeasureSpec(desiredHeight, MeasureSpec.EXACTLY)
} else {
heightMeasureSpec
}
super.onMeasure(widthMeasureSpec, measuredHeightSpec)
}
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
if (w > 0) applyLayoutSize(w)