0

Android app: I got a ListView in which each element has: -Three TextViews -One ImageView -One WebView

The content of the WebView is a formatted text: it has two text colors and it is justified. It works perfectly, but the WebView takes half a second to show up. I looked a few questions here on Stackoverflow: no answer worked. I really didn't catch what the problem is, 'cause the text is very short, like thirty characters, and the List ha like two elements by now!

I populate webViews on the getView() method of my CustomAdapter, this way:

holder.webDesc = (WebView) convertView.findViewById(R.id.hos_webView_Desc);
holder.webDesc.loadData(element.description, "text/html", "utf-8");

and the content on element.description is

<div style='text-align:justify;' bgcolor='#333333'>
<font color="#ff7f7f" size = 2>ABC </font>
<font color="#aaff7f" size = 2>DEFG</font>
</div>

end the WebView is declared in this way on .xml

<WebView
    android:id="@+id/hos_textView_why"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="@color/redS50B100"
    android:layout_marginLeft="@dimen/activity_horizontal_margin"
    android:layout_marginRight="@dimen/activity_horizontal_margin"
    android:layout_marginBottom="8dp"
/>

So I thought: am I populating wrong the WebView? If not, how can I speed up its load? Or, more drastically, there is an alternative to WebView which permits multi color managment and justification?

Simone Chelo
  • 706
  • 8
  • 25

1 Answers1

0

Try to add following to your Manifest.xml

android:hardwareAccelerated="true"

and this to your CustomAdapter:

holder.webDesc.setLayerType(View.LAYER_TYPE_HARDWARE, null);
Metehan
  • 729
  • 5
  • 22