This article describes the implementation method of the textView display insertion in Android. Share it for your reference, as follows:
The Android system provides three ways to insert pictures for TextView by default:
1、ImageSpan
2、
3、(left, top, right, bottom)
1. TextView uses ImageSpan to display images
ImageSpan span = new ImageSpan(this, .ic_launcher); SpannableString spanStr = new SpannableString("https://"); (span, ()-1, (), Spannable.SPAN_INCLUSIVE_EXCLUSIVE); (spanStr);
PS: For other spans related to SpannableString, check out:[Android Tutorial] TextView sets composite text using SpannableString
2. Use pictures on the web page
View article:[Android Tutorial] TextView displays web pages and pictures and custom tags parsed by Html class
3. Display pictures around TextView
("setCompoundDrawables"); Drawable d = getResources().getDrawable(.ic_launcher); (0, 0, 50, 50); //The image size must be set, otherwise it will not be displayed(d , null, null, null);
For more information about Android related content, please check out the topic of this site:Android development introduction and advanced tutorial》、《Android multimedia operation skills summary (audio, video, recording, etc.)》、《Summary of the usage of basic Android components》、《Android View View Tips Summary》、《Android layout layout tips summary"and"Android control usage summary》
I hope this article will be helpful to everyone's Android programming design.