Android create Spannable which does not wrap

自古美人都是妖i 提交于 2019-12-06 06:37:53

问题


I have a following issue with laying out text on Android. I'm basically trying to have two lines of text with minimal spacing and each should be styled differently. I've had quite good working solution with two singlelined TextViews one placed below the other, but I've been still getting a little bit cropped text on certain devices..

So I decided to switch to just one TextView an use Spannables instead which should be generally a better solution in all circumstances.

That means I needed to remove the single line property from my TextView -> in order to be able to wrap the line before starting the second Spannable..But there is an issue when is the text displayed at the first line actually longer than it..TextView wraps Automaticaly which is an unwanted behavior. Below you can see several screenshots, which should you better tell what I'm trying to achieve and where I'm now.

The first image shows new layout with spannables and you can see there the wrapped line as well. The second image is the initial version of the layout woth two textviews layed out verically in a LinearLayout.

There is also a problem it's actually an appwidget, that means I do not have an access to that textview instance directly. I have been thinking about ditching textviews at all and instead use just ImageView and render all manually on canvas..That seems like an overkill to me, so I'm looking for a better solution. Unfortunately I'm kind of out of ideas and knowledge:)

Thank you

来源:https://stackoverflow.com/questions/21148848/android-create-spannable-which-does-not-wrap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!