I am trying to add a webview to a scrollview that can display static HTML text with a transparent background. Here is the code
WebView descr = (WebView) view.findViewById(R.id.description); descr.setBackgroundColor(Color.TRANSPARENT); descr.loadData(desc, "text/html", "utf-8"); descr.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
If I do not set the value of setLayerType, I can see the text correctly. However, a flickering effect is added when scrolling. If the setLayerType line is added, the text for some pages disappears. This is what my layout looks like
<ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/title" > <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="10dp" android:descendantFocusability="blocksDescendants"> <ImageView android:id="@+id/icon" android:layout_width="fill_parent" android:layout_height="100dp" android:contentDescription="@id/title" android:paddingLeft="10dp" android:paddingRight="10dp" /> <WebView android:id="@+id/description" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingBottom="10dp" android:paddingTop="10dp" android:textAlignment="gravity" android:textSize="14sp" android:background="@null" android:focusable="false" /> </LinearLayout> </ScrollView>
This problem occurs when I install the .apk file on my mobile and not on the emulator. I am using Android version 4.1.2. Can someone tell me what needs to be done so that the text appears without a flickering effect and with a transparent background?
source share