Hanbit the Developer
[Kotlin] How to make 'instagram comment layout' using Span. 본문
https://rccode.tistory.com/entry/Kotlin-Set-indent-to-first-line-of-TextView-in-android
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
'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 |