TextView + Spanned实现图文混排以及点击交互

最近要实现图文混排的需求,webview过大,所以想到了用SpannableStringBuilder来实现。 不过参考了大量国内文章,大多数是教你如何实现图文混排,并没有提及图片点击交互的。有翻阅了一些国外文章,说的也不是很详细,于是花费时间鼓捣了一下,最终实现了TextView图文混排,加点击交互的效果,在这里给大家分享下以免后来者在此处浪费过多时间。

主要用到的有Spanned ClickSpan ImageSpan ImagerGetter Html 。
先看一下效果图:
这里写图片描述

我把它封装成了一个控件,使用的时候只要将它放到xml布局
下载地址:https://github.com/githubwing/RichTextView

实现思路

由于后台是传来的html,所以可以借助系统类Html来解析生成Spanned,再将SpannedString转换为ClickSpan,最终实现图文混排+图片交互效果。

后台先传来一段html,如下:

注意这里的第二个参数,是一个ImageGetter类型的接口,这里直接拿了Glide作者开发的Imagegetter来使用,他的作用是在spanned中加载图片。

国内的文章大多介绍到这里,实现了图文混排。。。然后就没有然后了。。可是尼玛我想点击放大啊有没有。。 莫急,接下来就告诉你们,如何点击交互。

其实就是将Spanned转换为clickspan,

嘛。。理论上这样就可以了,可是事实上,你会发现,点击图片根本没鸟反应!!!!!然后我有鼓捣了一会。。发现需要加上一句,才可以。

TextView + Spanned实现图文混排以及点击交互》有94个想法

  1. AnnmarieN Paris Saint Germain LouieKrau
    ZTOJeseni Los Angeles Galaxy AidaRuggl
    DBRCruznj Ukraina FelixBead
    Christoph Barcelona MistyCard
    JustineWh Turkiet AnnieWolf

  2. While made for convenience, auto-beginning plans likewise make your personal computer get longer to-boot and can load your taskbar tray with designs. (Image due to Microsoft) Click “Ctrl-Shift-Esc” or right-click the taskbar and select “Task Manager.” Step 2: Image thanks to Microsoft Change towards the “Startup” tab to find out a list of applications that begin with Windows. Image due to Microsoft Decide on a method and push “Eliminate” to stop it from working on startup. Image courtesy of Microsoft Press “Windows-R” and work “msconfig” to open the Machine Setup energy. Image thanks to Microsoft Start the “Startup” bill and uncheck any plans that you would like to prevent managing immediately. You might need to grow the gleam to see its contents: doubleclick the straight point between “Command” and “Location.” Phase 3: Should you choose “Exit Without Restart,” the options take effect the very next time you machine or change your personal computer on / off. Image courtesy of Microsoft The startup system listings do not incorporate technique services, that you will get to the Services bill in Msconfig on both Windows-7 and 8. Some programs run automatically utilizing companies in the place of startup goods, but the Services list also incorporates crucial Windows components, consequently eliminate something as long as you understand what you’re doing. Select “Normal Startup” on the Common case of Msconfig to re-help all incapable startup applications and services. In case a software prevents performing, nonetheless, undo the change.
    custom essay writing service

  3. I simply want to tell you that I’m all new to weblog and definitely enjoyed this blog site. Most likely I’m likely to bookmark your site . You amazingly have awesome posts. With thanks for sharing your web page.

  4. I have to express my appreciation to you for bailing me out of such a incident. Right after browsing throughout the online world and seeing ideas which are not beneficial, I assumed my entire life was gone. Living devoid of the answers to the problems you’ve solved by means of your report is a serious case, as well as ones that would have adversely damaged my career if I hadn’t encountered your web site. Your own personal skills and kindness in taking care of all the stuff was very helpful. I don’t know what I would have done if I had not encountered such a stuff like this. It’s possible to now look ahead to my future. Thanks a lot very much for the reliable and sensible help. I will not hesitate to suggest your site to anybody who should receive care on this issue.

  5. Thanks so much for providing individuals with such a special possiblity to check tips from here. It can be very good and jam-packed with a lot of fun for me and my office co-workers to visit your web site really 3 times in 7 days to study the new stuff you have. And lastly, we are at all times pleased with all the superb concepts you give. Selected two areas in this post are easily the most efficient I’ve ever had.

  6. California indigenous Taylor Negron, whose work involves both comedy and theatre, including functions in many iconic movies and tvshows from the 70s to the current has died. Being of Puerto Rican ancestry, Negron could occasionally perform national roles, but his talent would expand in the horrifying killer in “The Final Boy Scout” to the comical attack into Rodney Dangerfield???s living in “Easy-Money” where he competed a personality about to wed Rodney???s girl (Jennifer Jason Leigh). Negron also seemed with Miss Leigh in “Rapid Moments at Ridgemont High,” but while his part while the pizza deliveryman was essentially a cameo, the arena was therefore famous he was frequently acknowledged for this. Negron recalled his position in “The Past Boy Scout,” stating: “It wasn???t a stretch, however it emerged like a shock tome, since Bruce Willis, Tony Scott and Joel Silver had this concept inside their brain. I realized very early-on that Fran and dear, dear Tony Scott truly cared about hearings, therefore with wonderful detail they blonded my hair and provided me that irregular ???60???s slice. I donned Dolce & Gabbana apparel and I searched so weird and otherworldly, and just by the utter virtue of the fact that I had a firearm in my palm, that did every one of the acting for me.” In 2008 he wrote “The Unbearable Lightness of Being Taylor Negron ??? A Combination of Story and Tune,” which accomplished critical praise in the Edinburgh Comedy Festival. Negron???s act as an author parallels his achievement being an actor. He published the play “Gangster Earth,” and a large number of humor documents which have been posted in a variety of anthologies.
    professional article writing services

  7. Thanks a lot for providing individuals with an exceptionally splendid chance to discover important secrets from this site. It is often very awesome plus full of fun for me and my office fellow workers to search your site no less than three times per week to learn the newest issues you have. Of course, I am also at all times astounded for the awesome inspiring ideas you give. Certain 3 points in this post are undeniably the most suitable I’ve had.

  8. I just wanted to type a small comment so as to thank you for some of the wonderful pointers you are giving at this site. My rather long internet search has now been compensated with incredibly good know-how to go over with my colleagues. I would repeat that many of us site visitors are truly endowed to exist in a useful community with so many perfect people with very helpful plans. I feel quite happy to have used your web site and look forward to tons of more enjoyable times reading here. Thank you once again for everything.

  9. I have to express my love for your generosity for men and women who should have help on this important idea. Your very own dedication to passing the solution across had been rather effective and have frequently enabled individuals just like me to get to their ambitions. Your new valuable information implies this much to me and somewhat more to my mates. Best wishes; from all of us.

  10. I am glad for writing to make you be aware of what a extraordinary discovery my wife’s daughter found studying the blog. She realized many things, which include what it is like to possess an awesome teaching spirit to have the mediocre ones really easily grasp a number of impossible matters. You truly exceeded people’s expected results. Thank you for churning out those warm and helpful, trusted, educational and even fun thoughts on the topic to Julie.

  11. Needed to write you one tiny word in order to thank you the moment again on the breathtaking opinions you’ve discussed in this article. This has been so pretty open-handed with people like you to offer openly what exactly many people could possibly have distributed for an e-book to help with making some dough for themselves, and in particular seeing that you might well have tried it if you decided. Those guidelines as well acted to be the good way to realize that someone else have a similar dream just like my very own to grasp whole lot more with respect to this condition. I’m sure there are many more enjoyable moments ahead for people who scan through your site.

  12. Hello just wanted to give you a brief heads up and let you know a few of the pictures aren’t loading correctly. I’m not sure why but I think its a linking issue. I’ve tried it in two different web browsers and both show the same outcome.

  13. I really wanted to type a small message to be able to appreciate you for those awesome ideas you are giving out at this website. My long internet research has now been paid with brilliant facts and strategies to share with my two friends. I ‘d believe that most of us site visitors actually are unquestionably lucky to be in a really good network with so many awesome professionals with valuable tips and hints. I feel pretty happy to have encountered your entire web site and look forward to tons of more amazing times reading here. Thanks once again for a lot of things.

  14. Be sure that you have Silhouette Studio Designer Edition running and adhere to these easy actions to start! While it is crucial to have Silhouette Studio Designer Edition to import SVGs there is yet another step you’ve got to take to receive them actually cut. I am aware I’ve missed lots of nice anime collection, so should you have any suggestion, don’t hesitate to share about it in the comment section!

  15. Greetings there, just turned aware of your web page through Google, and discovered that it’s quite beneficial. I will take pleasure in in the event you retain such.

  16. Gday here, just got aware about your blogging site through The Big G, and realized that it is quite entertaining. I’ll appreciate should you decide carry on this idea.

  17. I just hope to tell you that I am new to having a blog and certainly enjoyed your write-up. More than likely I am probably to bookmark your blog post . You indeed have fantastic article materials. Be Grateful For it for swapping with us your very own domain information

  18. I have to voice my admiration for your kindness in support of folks that absolutely need assistance with this issue. Your real commitment to passing the message along turned out to be extraordinarily practical and has constantly allowed employees like me to realize their endeavors. Your helpful recommendations signifies much a person like me and substantially more to my office workers. Thanks a ton; from each one of us.

  19. Needed to send you that bit of remark to be able to thank you very much over again over the remarkable views you’ve documented on this site. It is certainly open-handed of people like you to allow unhampered all many of us would’ve advertised for an e-book to end up making some money for their own end, principally seeing that you might have tried it in case you desired. The advice additionally acted as a fantastic way to be sure that many people have similar keenness similar to my own to figure out lots more when considering this condition. I’m certain there are millions of more pleasant situations in the future for many who see your site.

  20. Thank you for all of the effort on this site. My mum really loves getting into internet research and it’s easy to see why. A number of us notice all concerning the powerful form you produce worthwhile things on your website and recommend participation from other people on the theme then our daughter is without a doubt becoming educated a lot of things. Enjoy the remaining portion of the year. You are performing a superb job.

  21. Thanks so much for providing individuals with such a marvellous chance to read in detail from this site. It is often very lovely plus packed with fun for me personally and my office colleagues to visit your web site nearly thrice per week to find out the new stuff you have. And definitely, I’m so actually contented with all the incredible strategies you serve. Some 2 tips in this posting are in reality the most beneficial I’ve had.

  22. It is appropriate time to make some plans for the future and it’s time to be happy. I’ve read this post and if I could I desire to suggest you few interesting things or advice. Maybe you can write next articles referring to this article. I desire to read even more things about it!

  23. Good ¡V I should definitely pronounce, impressed with your site. I had no trouble navigating through all the tabs and related info ended up being truly simple to do to access. I recently found what I hoped for before you know it in the least. Quite unusual. Is likely to appreciate it for those who add forums or anything, web site theme . a tones way for your customer to communicate. Excellent task..

  24. Its like you read my mind! You seem to know a lot about this, like you wrote the book in it or something. I think that you can do with a few pics to drive the message home a little bit, but other than that, this is fantastic blog. A fantastic read. I’ll definitely be back.

  25. My husband and i got absolutely satisfied Louis could conclude his reports while using the ideas he acquired in your weblog. It is now and again perplexing to simply be making a gift of concepts that the others might have been making money from. And we also already know we need the blog owner to be grateful to for that. The type of explanations you’ve made, the easy web site navigation, the friendships you will help to create – it’s all overwhelming, and it is facilitating our son and the family reason why the topic is cool, and that’s very vital. Thanks for all!

  26. I’m extremely impressed with your writing skills and also with the layout on your weblog. Is this a paid theme or did you modify it yourself? Anyway keep up the excellent quality writing, it’s rare to see a great blog like this one today..

  27. I loved as much as you’ll receive carried out right here. The sketch is attractive, your authored subject matter stylish. nonetheless, you command get got an nervousness over that you wish be delivering the following. unwell unquestionably come further formerly again since exactly the same nearly very often inside case you shield this increase.

  28. hi!,I like your writing very much! share we be in contact extra about your post on AOL? I require an expert in this house to solve my problem. May be that is you! Looking ahead to peer you.

  29. I have been surfing online more than three hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my opinion, if all webmasters and bloggers made good content as you did, the internet will be much more useful than ever before.

  30. I am no longer sure the place you’re getting your information, but good topic. I must spend some time finding out much more or working out more. Thanks for fantastic information I was looking for this information for my mission.

  31. I’m just writing to let you understand what a fine experience my friend’s child experienced using the blog. She even learned a wide variety of issues, not to mention what it is like to have a wonderful coaching heart to have certain people clearly learn about several very confusing issues. You actually surpassed visitors’ expectations. Many thanks for rendering those important, healthy, explanatory and as well as cool tips about that topic to Janet.

  32. I merely intend to notify you that I am new to blog posting and undeniably liked your webpage. Likely I am going to bookmark your blog post . You definitely have wonderful article content. Get Pleasure From it for swapping with us all of your website post

  33. I needed to draft you the little note to be able to say thanks yet again for your personal spectacular concepts you’ve shown in this article. This has been simply wonderfully open-handed of people like you to allow publicly what exactly most of us might have marketed as an e-book in making some cash for themselves, notably now that you could possibly have done it in the event you wanted. The guidelines also acted like the easy way to understand that the rest have the identical dream the same as my own to grasp a whole lot more around this issue. Certainly there are thousands of more fun situations ahead for many who read through your blog.

  34. When higher education and university professors assume their college students to write complicated papers, they do not bother detailing how that content material is supposed to generally be done. They assume pupils are already mindful of your expectations of academic writing, so they must quickly begin the process of completing top-notch content material with no earning objections. The fact is, most learners have truly serious problems with these assignments.
    http://www.locave-concepts.be/2011/04/25/made-to-order-writing-program-essays-and-well/

  35. I have to express some thanks to you just for bailing me out of this challenge. As a result of exploring through the search engines and meeting opinions which were not beneficial, I assumed my entire life was gone. Existing without the presence of approaches to the issues you’ve sorted out all through your entire website is a serious case, as well as the ones that might have negatively affected my career if I had not noticed your web blog. Your own training and kindness in handling all the things was crucial. I’m not sure what I would have done if I had not come upon such a thing like this. It’s possible to at this moment look forward to my future. Thanks for your time so much for your reliable and results-oriented help. I won’t think twice to refer the website to anyone who needs direction about this issue.

  36. I simply want to show you that I am new to online blogging and utterly admired your review. Likely I am inclined to save your blog post . You undoubtedly have fabulous article content. Be Grateful For it for discussing with us your current url page

  37. Thank you a lot for providing individuals with such a wonderful chance to read articles and blog posts from here. It’s always very nice and full of a lot of fun for me personally and my office co-workers to visit your web site more than 3 times in 7 days to learn the new guides you have got. And lastly, we’re actually happy for the gorgeous solutions served by you. Some 1 ideas in this article are in fact the most impressive I’ve had.

  38. I have been surfing online more than three hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. In my opinion, if all web owners and bloggers made good content as you did, the net will be much more useful than ever before.

  39. I would like to express my affection for your kindness giving support to all those that absolutely need help with your theme. Your real commitment to passing the solution all through turned out to be particularly useful and has all the time enabled professionals just like me to reach their endeavors. Your entire invaluable suggestions indicates much a person like me and further more to my fellow workers. Thanks a ton; from everyone of us.

  40. Thank you for every one of your hard work on this site. My mum really likes making time for investigation and it’s obvious why. We hear all concerning the lively mode you create invaluable tips by means of your web blog and as well attract contribution from some others on the situation so my simple princess is truly learning a lot. Take pleasure in the remaining portion of the new year. You’re the one performing a first class job.

  41. Excellent goods from you, man. I’ve understand your stuff previous to and you are just extremely magnificent. I really like what you have acquired here, certainly like what you’re saying and the way in which you say it. You make it enjoyable and you still take care of to keep it sensible. I can’t wait to read much more from you. This is really a tremendous site.

  42. My husband and i have been so ecstatic that Ervin managed to conclude his researching from the precious recommendations he made using your web page. It’s not at all simplistic to just possibly be giving away procedures others could have been making money from. Therefore we do know we have got the writer to be grateful to for this. The illustrations you’ve made, the straightforward web site navigation, the relationships you can assist to engender – it’s got mostly exceptional, and it’s really aiding our son and us consider that that content is amusing, and that is highly serious. Many thanks for all the pieces!

  43. certainly like your website however you have to test the spelling on quite a few of your posts. Many of them are rife with spelling problems and I to find it very bothersome to tell the reality on the other hand I will certainly come again again.

  44. You could definitely see your expertise in the paintings you write. The world hopes for more passionate writers like you who aren’t afraid to mention how they believe. At all times follow your heart. “There are only two industries that refer to their customers as users.” by Edward Tufte.

  45. Good website! I truly love how it is easy on my eyes and the data are well written. I am wondering how I might be notified when a new post has been made. I’ve subscribed to your RSS feed which must do the trick! Have a nice day!

  46. hi!,I really like your writing very much! share we keep up a correspondence extra approximately your post on AOL? I require a specialist on this space to unravel my problem. Maybe that is you! Having a look forward to peer you.

  47. I must convey my gratitude for your generosity for folks that have the need for help on this one theme. Your special dedication to getting the solution all over was pretty invaluable and have frequently allowed somebody much like me to achieve their endeavors. The warm and helpful publication entails a great deal a person like me and especially to my fellow workers. Thanks a lot; from all of us.

  48. I wanted to draft you one very little word to help say thanks as before considering the pleasing knowledge you’ve documented on this page. This has been really pretty generous of people like you to provide unreservedly just what many people could possibly have supplied for an e book to make some profit for their own end, certainly considering that you might have tried it if you desired. The tactics in addition worked to be a great way to realize that other individuals have the same keenness just like my personal own to find out whole lot more pertaining to this problem. I believe there are several more pleasant opportunities in the future for individuals who read through your website.

  49. Great beat ! I wish to apprentice while you amend your site, how could i subscribe for a blog website? The account helped me a acceptable deal. I had been a little bit acquainted of this your broadcast provided bright clear concept

  50. I must express my admiration for your kind-heartedness in support of individuals who absolutely need assistance with in this content. Your special commitment to passing the message across ended up being rather functional and have without exception helped professionals just like me to achieve their endeavors. Your personal insightful facts means this much a person like me and extremely more to my office colleagues. Many thanks; from each one of us.

  51. I precisely needed to appreciate you all over again. I do not know what I would have taken care of in the absence of the entire tricks discussed by you concerning that field. This was a hard matter in my position, but viewing the very specialized way you processed it made me to cry for happiness. Extremely happy for your advice as well as believe you comprehend what a powerful job you are always putting in educating the rest by way of a blog. I know that you have never met all of us.

发表评论

电子邮件地址不会被公开。