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. R.java Not foudn exception

Hi all,

at compilation all is OK: my project is compiling correctly and it
installed correctly too.

In my programme I've something like that
Toast.makeText(this, this.getResources().getString(R.string.value),
Toast.LENGTH_SHORT).show();

And my app crash with following error
06-08 16:39:58.521: ERROR/AndroidRuntime(873):
android.content.res.Resources$NotFoundException: String resource ID
#0x7f04000d
06-08 16:39:58.521: ERROR/AndroidRuntime(873):     at
android.content.res.Resources.getText(Resources.java:155)
06-08 16:39:58.521: ERROR/AndroidRuntime(873):     at
android.content.res.Resources.getString(Resources.java:208)

My R.java file contains this key
public static final int value=0x7f04000d;

So why the resource isn't found at execution?

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

2. How can I do this?

This is what I need.  I need to allow the user to continue to work at
the same time I need to run one of my methods every 60 seconds.  I
looked at TimerTask, but I am not sure it this will do the job.  I tried
to implement TimerTask but the compiler didn't like it.


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

3. ListView items in Activity Persist on G1 keyboard slideout, but not Dialog list items

4. LayoutAnimatorController "IsDone"

5. Dalvik Version

6. Eclipse question...

7. Browser App: Soft Keyboard int