【问题标题】:How to fill the empty spaces with content below the Image in android如何用android中图像下方的内容填充空白空间
【发布时间】:2012-11-23 10:14:54
【问题描述】:

我的 xml 布局中有一个 ImageView 和一个 TextView。我想在ImageView右侧显示我通过webservice获得的文本。我可以使用那个 TextView 来显示该文本吗?

我试图在 xml 布局中给 android:singleLine="false" 但没有用。

【问题讨论】:

    标签: android android-layout xml-layout


    【解决方案1】:

    https://github.com/deano2390/flowtextview

    示例用法:

     <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
    • 您不必将其转换为 html。不要只使用 spanable tv.setText(yourtextfromwebservice);
    • 我如何将该网络服务文本转换为 html @talhakosen
    • 我在那里编辑了我的帖子检查,有两种使用 flowtextview。其中一个是html,另一个是纯文本。
    • 懒惰。甚至图书馆的样本也不能顺利滚动
    【解决方案2】:

    这里已经讨论过了: Textview wrap around View 在这里wrap text view around img view

    显然,一个解决方案是使用 Spannable 和 ImageSpan 描述是这个答案Textview wrap around View

    另一种解决方案是使用 webview 并让您在 html 中进行布局。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-09
      • 1970-01-01
      • 2012-08-30
      • 2019-05-26
      • 1970-01-01
      相关资源
      最近更新 更多