如何在Android中填充图像下方的空白区域

18

我在xml布局中有一个ImageView和一个TextView。我想在ImageView的右侧显示从webservice获取的文本。我能否使用这个TextView显示该文本?

输入图像描述

我尝试在xml布局中使用android:singleLine="false",但没有用。

2个回答

23

https://github.com/deano2390/flowtextview

screenshot

Example usage:

 <com.pagesuite.flowtext.FlowTextView
     android:id="@+id/tv"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content" >

     <ImageView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentLeft="true"
         android:layout_alignParentTop="true"
         android:padding="10dip"
         android:src="@drawable/android" />

     <ImageView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:layout_alignParentRight="true"
         android:layout_marginTop="400dip"
         android:padding="10dip"
         android:src="@drawable/android2" />

</com.pagesuite.flowtext.FlowTextView>

你的代码:

用于文本:

tv = (FlowTextView) findViewById(R.id.tv);                  
tv.setText("my string"); // using plain text    
tv.invalidate(); // call this to render the text

对于HTML:

tv = (FlowTextView) findViewById(R.id.tv);              
Spanned spannable = Html.fromHtml("<html ... </html>");
tv.setText(spannable);  // using html
tv.invalidate(); // call this to render the text

我正在从 Web 服务获取文本,如何将该文本设置为 HTML? - user1497804
你不需要将它转换为HTML。不要使用Spannable,只需使用tv.setText(yourtextfromwebservice); - Talha
我该如何将那个 Web 服务的文本转换为 HTML?@talhakosen - user1497804
我编辑了我的帖子,请在那里查看。FlowTextView 有两种用法,一种是 HTML,另一种是纯文本。 - Talha
卡顿。即使库的示例也无法平滑滚动。 - DeltaCap019

1

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接