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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user