Android - how to build webview? -


i using webviews inside of viewflipper display text can full justification , other aspects of html.

webview welcometext = new webview(this); welcometext.setverticalscrollbarenabled(false); welcometext.setbackgroundcolor(0x00000000); ((linearlayout) findviewbyid(r.id.welcometext)).addview(welcometext); welcometext.loaddata(getstring(r.string.welcome_text), "text/html", "utf-8"); 

and xml:

<linearlayout android:id="@+id/welcometext" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="16dip" /> 

this works great except 1 small annoyance wish eliminate. when switch child view webview first time on opening app, webview height not seem set causes sort of accordion affect (so webview kind of slides place pushing down rest of view). going next child view webview , same happens on one. going previous view works ok view built fully. im not sure if related webcore warning in logcat during oncreate

"06-04 19:43:48.176: w/webcore(8416): can't viewwidth after first layout" 

how can set webview set right heights/widths when view doesnt jump view?

you need add webview layout parameters... example:

webview welcometext = new webview(this); welcometext.setverticalscrollbarenabled(false); welcometext.setbackgroundcolor(0x00000000);  float density = getresources().getdisplaymetrics().density; int webview_height=100; linearlayout.layoutparams layoutparams = new linearlayout.layoutparams(layoutparams.match_parent, (int) (webview_height*density));  ((linearlayout) findviewbyid(r.id.welcometext)).addview(welcometext,layoutparams); welcometext.loaddata(getstring(r.string.welcome_text), "text/html", "utf-8"); 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -