Hanbit the Developer
[Kotlin] How to make 'instagram comment layout' using Span. 본문
Mobile/Android
[Kotlin] How to make 'instagram comment layout' using Span.
hanbikan 2021. 8. 10. 16:01https://rccode.tistory.com/entry/Kotlin-Set-indent-to-first-line-of-TextView-in-android
[Kotlin] Set indent to first line of TextView in android
- Description To do so, you should use Span, LeadingMarginSpan. In a nutshell, Span is used to set text style in detail, and LeadingMarginSpan is one of the styles that is related to margin, espe..
rccode.tistory.com
This post is advanced version of above link. So, If you want to get some more descriptions for it in detail, visit the link.
- Description
Before starting, you should know that there are 2 text views(text_nickname, text_content), and they are overlapped like this.
The text_content has a indent only for a first line.
val spannable = SpannableString(contentTextView.text)
val span = LeadingMarginSpan.Standard(nicknameTextView.width + 10, 0)
spannable.setSpan(span, 0, spannable.count(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
contentTextView.text = spannable
Use SpannableString and LeadingMarginSpan referencing nicknameTextView.width.
- Result
'Mobile > Android' 카테고리의 다른 글
[Kotlin] Delete whole directory in android (0) | 2021.08.19 |
---|---|
[Kotlin] Get URI from byte array in android (0) | 2021.08.19 |
[Kotlin] Set indent to first line of TextView in android (0) | 2021.08.10 |
[Kotlin] TextView의 더보기 기능 구현 (0) | 2021.08.08 |
[Retrofit2] Send Post Request With Empty Body (0) | 2021.07.21 |