2015-12-09 40 views
0

我有textview我想在一些文本後給水平線。如何在不使用webview的情況下從HTML中使用水平線

例如,

String line1="Hello Developer"; 
String line2-"Bye All"; 

textView.setText(Html.fromHtml(line1+"<hr>"+line2); 

<hr>標籤沒有在這裏工作。 如何顯示使用fromHtml而不使用webview。

+0


代替


Sathish

+0

@Palakp你找到一個解決方案?我需要這個水平線(只有一個textview ...) – NinjaOnSafari

回答

0

因爲<hr>不支持標籤。下面是()由Html.fromHtml支持標籤

<a> (supports attribute "href") 
<b> 
<big> 
<blockquote> 
<br> 
<cite> 
<dfn> 
<div> 
<em> 
<font> (supports attributes "color" and "face") 
<i> 
<img> (supports attribute "src". Note: you have to include an ImageGetter to handle retrieving a Drawable for this tag) 
<p> 
<small> 
<strong> 
<sub> 
<sup> 
<tt> 
<u> 
0

HR標籤沒有在外面的Android的WebView支持。

嘗試以下解決方案使用

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/LinearLayout" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal" 
    android:layout_marginTop="16dp" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="center_horizontal" 
     android:padding="10dp" 
     android:text="Hello Developer" /> 

    <View 
     android:layout_width="2dp" 
     android:layout_height="wrap_content" 
     android:background="#FFFFFF" /> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:gravity="center_horizontal" 
     android:padding="10dp" 
     android:text="Bye All" /> 

</LinearLayout> 
+0

不,我不能使用視圖。我希望在一個文本視圖中。 – Palakp

相關問題