Created
January 30, 2019 07:59
-
-
Save tfcporciuncula/f351bd95d398ef2658ce90c85bd1b676 to your computer and use it in GitHub Desktop.
TextView extension to dynamically set maxLines
This file contains hidden or 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
fun TextView.setMaxLinesToEllipsize() = doOnPreDraw { | |
val numberOfCompletelyVisibleLines = (measuredHeight - paddingTop - paddingBottom) / lineHeight | |
maxLines = numberOfCompletelyVisibleLines | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment