hanggrian / socialview

Android TextView and EditText with hashtag, mention, and hyperlink support
http://hanggrian.com/socialview/
Apache License 2.0
323 stars 81 forks source link

Add Support for RichTextFormatting #40

Closed wanGiB closed 3 years ago

wanGiB commented 6 years ago

Hello, nice library here. I wanted to ask if it's possible to add support for rich text formatting like on WhatsApp and Slack such that when a user types any group of words between here it becomes bold and here becomes italic...

hanggrian commented 6 years ago

Thanks!

Though it's very much possible and can be easily implemented (given that pattern and colorizing logic is already there), I'm not sure if this is needed. Most social media text fields do not support this behavior, except of course if we're talking about online forums.

But this library is always open for improvement, let's wait for others' input on this.

devingDev commented 6 years ago

Sounds nice but it should be togglable.

FidaMOhsin commented 3 years ago

Hi @hendraanggrian Can you please tell me have you fixed this issue?

NehaKushwah993 commented 3 years ago

this html is not working

hanggrian commented 3 years ago

I believe hyperlink colorization is working and configurable now, so I'm closing this issue.

guizot commented 2 years ago

Bro bagimana ya caranya supaya bisa bold text menggunakan SocialTextView? saya pakai Html.fromHtml tapi tidak bold text nya?

hanggrian commented 2 years ago

@guizot Malam bang. Karena semua TextView yang implementasi SocialView akan reset spanning setiap text berubah, bold spanningnya mesti manual di TextWatcher:

textView.addTextChangedListener {
    (textView.text as Spannable).setSpan(StyleSpan(Typeface.BOLD), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
}
guizot commented 2 years ago

Implementasinya gmn ya bro? TextWatcher di taruh dimana?

ini XML saya

<com.hendraanggrian.appcompat.widget.SocialTextView
                    android:id="@+id/chat_message_text_self"
                    android:layout_width="wrap_content"
                   android:layout_height="wrap_content"
                    android:drawablePadding="8dp"
                    app:hashtagColor="@color/colorPrimaryDark"
                    app:mentionColor="@color/colorPrimaryDark"
                    app:hyperlinkColor="@color/colorPrimaryDark"/>`

ini di Adapter saya

chat_message_text_self.text = Html.fromHtml(message).trim()