Android imitates Sina Weibo, QQ space and other posts (1)

Textview is usually used to display ordinary text, but sometimes it is necessary to set the style and event of some of the text. The Android system processes the specified text through the spannablestring class. There are many places used in practical applications, such as the display of expressions during chat, the display of topics in the circle of friends or community, @ friends display and click, etc., and the display of keywords in different colors

1. Backgroundcolorspan background color

2. Clickablespan text can be clicked, and there are click events

3. Foregroundcolorspan text color (foreground color)

4. Maskfilterspan decoration effects, such as blurmaskfilter and embossmaskfilter

7. Strikethrough span strikethrough (DASH)

8. Suggestionspan is equivalent to a placeholder and is generally used in the edit text input box. When you double-click this text, a prompt box will pop up to select some suggested (recommended) text, and the selected text will replace this placeholder. It is used more in input method.

9. Underlinespan underline

10. Absolutesizespan absolute size (text font)

11. Dynamicdrawablespan sets the picture to align based on the text baseline or bottom.

12. Imagespan pictures

13. Relativesizespan relative size (text font)

14. Scalexspan scales based on the X axis

15. Stylespan font style: bold, italic, etc

16. Subscriptspan subscript (used in mathematical formula)

17. Superscript span superscript (used in mathematical formula)

18. Textappearance span text appearance (including font, size, style and color)

19. Typefacespan text font

20. Urlspan text hyperlink

Download: https://github.com/LineChen/SpannableStringDemo

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>