GridView xml中的代码
<cn.zhiup.mobile.main.allcourse.WrapHeightGridView
android:id="@+id/typeName"
android:background="@color/white"
android:verticalSpacing="@dimen/x15"
android:numColumns="3"
android:paddingBottom="@dimen/x20"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
复制代码
自定义GridView代码
import android.content.Context
import android.util.AttributeSet
import android.widget.GridView
class WrapHeightGridView(context: Context, attrs:AttributeSet): GridView(context,attrs) {
override fun onMeasure(widthMeasureSpec:Int,heightMeasureSpec:Int){
var expandSpec:Int = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE/2,MeasureSpec.AT_MOST)
super.onMeasure(widthMeasureSpec, expandSpec);
}
}
复制代码
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END