环绕IMG文字版 [英] wrap text view around img view

查看:148
本文介绍了环绕IMG文字版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

晚上好,

我想环绕像问题的图像视图我的文字是问在这里:

I am trying to wrap my text around an image view like the question is asking here:

TextView的周围查看包装

在景观。

但我想这样做的HTML / CSS。再加上,这个问题是2岁。我希望有人想出了一个变通与此有关。

but I wish to not do it in HTML / CSS. plus, that question is 2 years old. I am hoping someone has figured out a work around with this.

另外,我要保持我的肖像认为它是即没有包装的文本视图下的IMG视图的方式。

Also, I wish to keep my portrait view the way it is with the img view under the text view i.e. no wrapping.

谁能帮我?

推荐答案

围绕我一个工作,能想到把我的头顶部,并从与的TextView 格式,最好的办法是有,说,一个 RelativeLayout的,只是把它里面的3个独立的意见。这将重新present的的TextView 这是旁边的形象,的ImageView 本身旁边的文本,再过去的TextView 下的第一个文本,但与 layout_width =match_parent。有没有其他的方式与做的的TextView 的ImageView 否则。

A work around I can think off the top of my head and from previous issues with TextView formatting, the best way is to have, say, a RelativeLayout, and just place 3 separate Views inside of it. It will represent the TextView that is right next to the image, the ImageView itself next to the text, and then the last TextView under the first text, but with the layout_width="match_parent". There is no other way to do this with the TextView or ImageView otherwise.

编辑:

其他唯一的解决办法,我相信,如果你是在使用1 TextView的这样的意图,你能做到的,我会建议使用 SpannableStringBuilder SpannableString 。我最初没有给你,作为一个特定原因的选项。如果你回到你张贴在你的问题的链接,其中一个答案说,他们找到了答案。我相信,人链接到一个很好的资源,但他们错了你的需求是什么。当使用 SpannableStringBuilder ,你基本上是创建一个字符串,可以有许多潜在的不同版本的单串为一体,就像3种不同的颜色在一个字符串,或3串不同的大小,都在同一个的TextView 。就像你所需要的。

The only other workaround I believe you can do if you are so intent on using 1 TextView, I would suggest using SpannableStringBuilder with SpannableString. I didn't originally give you that as an option for a specific reason. If you go back to that link you posted on your question, one of the answers say they found an answer. I believe that person linked to a good resource, but they are wrong for what your needs are. When using SpannableStringBuilder, you are essentially creating a string that can have potentially many different version of a single string into one, like 3 different colors on a single string, or strings with 3 different sizes, all in one TextView. Like what you need.

现在关于把图像,并有周围的文本换很好,但它不是那么简单,这例子是不是你所需要的联系洽谈。你可以做的是提供这一切在一个的TextView 是添加换行后,你知道图像的前几行会是正确的,然后这样做后的图像。但事实是它仍然需要走了 RelativeLayout的。但是,而不是两个TextViews你只需要一个。只需将TextView的在任何父是左上角和ImageView的顶端右侧任何的父。这模拟一个浮动元素。但我认为这样做的方法是比它的价值更多的麻烦。难道真的是因为你所要做的计算,以弄清楚在何处放置换行符,等等。你最好还是使用两个的TextView S在这使它看起来像你需要。所以,在我看来,请勿使用 SpannableStringBuilder ,但如果你不介意试图找出所有的间距,这确实给你什么,你需要用一个TextView的。

Now the link talks about putting an image and having the text wrap around it nicely, but its not that simple, and that example isn't what you need. What you could do to provide it all in one TextView is to add line breaks after the first few lines where you know the image will be to the right, and then not do so after the image. But the thing is it still needs to go in a RelativeLayout. But instead of two TextViews you only need one. Just place the TextView at the top left of whatever the parent is and the ImageView to the top right of whatever the parent is. This simulates a floating element. But I think doing it that way is more trouble than its worth. It really is because you have to do calculations to figure out where to put the line breaks, etc. You are better off using two TextViews in which to make it look like you need. So in my opinion, DO NOT USE SpannableStringBuilder, but if you do not mind trying to figure out all that spacing, that does give you what you need with a single TextView.

这篇关于环绕IMG文字版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆