1.5 SDK problem with WebView.getZoomControls()

by Mariano Kamp » Wed, 29 Apr 2009 03:34:04 GMT


Sponsored Links
 Yeah, I have the same problem.
Anyone?

Is the suddenly breaking and now deprecated getZoomControls() considered
private API?






--~--~---------~--~----~------------~-------~--~----~



1.5 SDK problem with WebView.getZoomControls()

by Jason Parekh » Wed, 29 Apr 2009 04:30:58 GMT


 The preferred API is
WebView.getWebSettings().setBuiltInZoomControls(true).  The new API is
simpler in that just setting the flag will automatically add/hide the
zoom controls.  It will also have better performance on the G1 and
some other devices due to it being hardware composited on top of the
WebView instead of software compositing.

Unfortunately, I'm not sure why you're seeing layout issues with the
old zoom controls.  Could you try changing the LinearLayout's
layout_width to fill_parent?  If this does not work, could you please
post a screenshot?

jason






--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


1.5 SDK problem with WebView.getZoomControls()

by Mariano Kamp » Thu, 30 Apr 2009 00:33:24 GMT


 he following is butt ugly and should not be necessary in a perfect world,
but works for me:

private void createWebView(View parent) {

webView = (WebView) parent.findViewById(R.id.content_web_view);

webView.setWebViewClient(new EmbeddedWebViewClient());


Method setBuiltInZoomControlsMethod = null;

WebSettings webSettings = webView.getSettings();

try {

setBuiltInZoomControlsMethod = webSettings.getClass().getMethod(
"setBuiltInZoomControls",

new Class[] { boolean.class });

} catch (SecurityException e) {

} catch (NoSuchMethodException e) {

}


if (setBuiltInZoomControlsMethod != null) {

try {

setBuiltInZoomControlsMethod.invoke(webSettings, new Object[] { true });

} catch (IllegalArgumentException e) {

} catch (IllegalAccessException e) {

} catch (InvocationTargetException e) {

}

} else {

FrameLayout zoomControlContainer = (FrameLayout) findViewById(R.id.
browse_zoom);

zoomControlContainer.addView(webView.getZoomControls());

webView.getZoomControls().setVisibility(View.GONE);

}

}

I tested it with 1.1 and 1.5.

On Wed, Apr 29, 2009 at 8:47 AM, Mariano Kamp <mariano.k...@gmail.com>wrote:


--~--~---------~--~----~------------~-------~--~----~



1.5 SDK problem with WebView.getZoomControls()

by Jason Parekh » Thu, 30 Apr 2009 01:16:25 GMT


 


I saw your subsequent post about using reflection to try to enable the
new zoom (thanks for posting that so others can re-use), but just in
case you want to fully go back to the old way (which I don't recommend
because of worse performance), try:

<FrameLayout
  android:id="@+id/browse_zoom"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:layout_centerHorizontal="true"
  android:layout_alignParentBottom="true" />

jason

--~--~---------~--~----~------------~-------~--~----~



1.5 SDK problem with WebView.getZoomControls()

by Mariano Kamp » Thu, 30 Apr 2009 02:29:31 GMT


 Jason, thanks, I just tried that and, as you say, it works too.
Regarding performance you talk about the lack of HW acceleration for the old
way or is it layout performance you talk about?






--~--~---------~--~----~------------~-------~--~----~



1.5 SDK problem with WebView.getZoomControls()

by Jason Parekh » Thu, 30 Apr 2009 02:48:54 GMT


 


Not a problem.  I was referring to the lack of HW acceleration for the old way.

jason




--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Review Galaxy tab donk

Dear om Dol dan yang lainnya,

Berhubung baru rame di kantor .. Boleh donk di repiew untuk Galaxy Tabnya .... 
( Telat.com yah )

Tararengkyu yah ...

NT

Sent from my BlackBerry wireless device from XL GPRS/EDGE/3G network

-- 
===============

2. (WTB) Accessories Fascinate

Dear RR,

Bagi seller yg punya acc fascinate japri saya ya, susah bgt nih nyari acc
nya

Thanks

-- 
===============

3. Cara liat apa yg sedang sync?

4. Gagal upgrade stream ke froyo & sharing usb modem via router?

5. Mohon info root ASUS a10

6. Tautan unduhan/apk Jakarta Post

7. NFS Shift di CM7 GingerBread