Merge branch 'feature-GHZS-1064' into 'dev-5.20.0'
fix:【光环助手】多版本下载面板-版本说明显示问题 https://jira.shanqu.cc/browse/GHZS-1064 See merge request halo/android/assistant-android!674
This commit is contained in:
@ -0,0 +1,31 @@
|
||||
package com.gh.gamecenter.common.view
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.widget.LinearLayout
|
||||
|
||||
class MaxHeightLinearLayout @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : LinearLayout(context, attrs, defStyleAttr) {
|
||||
private var mMaxHeight = 0
|
||||
|
||||
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
|
||||
val heightMode = MeasureSpec.getMode(heightMeasureSpec)
|
||||
var heightSize = MeasureSpec.getSize(heightMeasureSpec)
|
||||
if (mMaxHeight != 0 && (heightMode == MeasureSpec.EXACTLY || heightMode == MeasureSpec.AT_MOST || heightMode == MeasureSpec.UNSPECIFIED)) {
|
||||
heightSize = heightSize.coerceAtMost(mMaxHeight)
|
||||
}
|
||||
val maxHeightMeasureSpec = MeasureSpec.makeMeasureSpec(
|
||||
heightSize,
|
||||
heightMode
|
||||
)
|
||||
super.onMeasure(widthMeasureSpec, maxHeightMeasureSpec)
|
||||
}
|
||||
|
||||
fun setMaxHeight(maxHeight: Int) {
|
||||
mMaxHeight = maxHeight
|
||||
requestLayout()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user