package com.gh.gamecenter.home.custom.adapter

import android.content.Context
import android.util.AttributeSet
import com.gh.gamecenter.common.utils.dip2px

/**
 *  宽度不受父布局限制的 TextView
 *  使用场景 ：子布局超出父布局，并且宽度可能长于父布局
 *  @see CustomHomeRecommendItemGridAdapter
 */
class WidthUnlimitedTextView @JvmOverloads constructor(
    context: Context,
    attr: AttributeSet? = null,
    def: Int = 0
) : androidx.appcompat.widget.AppCompatTextView(context, attr, def) {

    val MAX_WIDTH = 1000F.dip2px()

    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
        super.onMeasure(MeasureSpec.makeMeasureSpec(MAX_WIDTH, MeasureSpec.AT_MOST), heightMeasureSpec)
    }

}