Created
August 12, 2018 07:08
-
-
Save itmammoth/f8bbf787c6854932d45a23961617d23a to your computer and use it in GitHub Desktop.
スクロールしない高さ自動調整のListView ref: https://qiita.com/itmammoth/items/ba84711e646f625c98e0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NonScrollListView : ListView { | |
constructor(context: Context) : super(context) | |
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) | |
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) | |
init { | |
isVerticalScrollBarEnabled = false | |
isHorizontalScrollBarEnabled = false | |
} | |
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { | |
val customHeightMeasureSpec = View.MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE shr 2, View.MeasureSpec.AT_MOST) | |
super.onMeasure(widthMeasureSpec, customHeightMeasureSpec) | |
layoutParams.height = measuredHeight | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment