The 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 <[email protected]>wrote:
> Hey Jason,
> thanks for showing an interest in that ;-)
>
> I attached a before screenshot from 1.1, an after screenshot from cupcake
> and an after2 screenshot also from cupcake, but fill_parent as you
> suggested.
>
> <?xml version="1.0" encoding="utf-8"?>
>
> <com.newsrob.widget.RelativeLayout
>
> xmlns:android="http://schemas.android.com/apk/res/android"
>
> android:id="@+id/show_entry_container"
>
> android:background="#0f0"
>
> android:layout_width="fill_parent"
>
> android:layout_height="fill_parent">
>
>
> <!-- @id/swipe_container -->
>
> <include
>
> layout="@layout/list_row"
>
> android:layout_alignParentTop="true"
>
> android:background="#00f" />
>
>
> <WebView
>
> android:id="@+id/content_web_view"
>
> android:layout_width="fill_parent"
>
> android:layout_height="fill_parent"
>
> android:layout_below="@id/swipe_container"
>
> android:layout_alignParentBottom="true"
>
> android:textSize="9sp" />
>
>
> <FrameLayout
>
> android:id="@+id/browse_zoom"
>
> android:layout_width="wrap_content"
>
> android:layout_height="wrap_content"
>
> android:layout_centerHorizontal="true"
>
> android:layout_below="@id/swipe_container" />
>
>
> <Button
>
> android:id="@+id/prev"
>
> android:layout_width="wrap_content"
>
> android:layout_height="wrap_content"
>
> android:layout_alignParentLeft="true"
>
> android:layout_centerVertical="true"
>
> android:enabled="false"
>
> android:visibility="invisible"
>
> android:background="@drawable/btn_camera_arrow_left" />
>
>
> <Button
>
> android:id="@+id/next"
>
> android:layout_width="wrap_content"
>
> android:layout_height="wrap_content"
>
> android:layout_alignParentRight="true"
>
> android:layout_centerVertical="true"
>
> android:visibility="invisible"
>
> android:background="@drawable/btn_camera_arrow_right" />
>
>
> </com.newsrob.widget.RelativeLayout>
>
> Any idea how to go about this?
>
> Just in case you're wondering why I have my own "RelativeLayout", I
> haven't, but I show on screen controls (prev/next) and need access to
> dispatchTouchEvent() and I know it sux to subclass for that, but I didn't
> know how to do that any other way.
> The actual relative layoit functionality is not altered though.
>
> Hopefully this will be the last issue I have to do fix for cupcake
> compatibility. Well, there is still a problem with preference changes not
> propagating... oh my.
>
> Cheers,
> Mariano
>
>
> On Tue, Apr 28, 2009 at 10:30 PM, Jason Parekh <[email protected]>wrote:
>
>>
>> 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
>>
>> On Tue, Apr 28, 2009 at 3:33 PM, Mariano Kamp <[email protected]>
>> wrote:
>> > Yeah, I have the same problem.
>> > Anyone?
>> > Is the suddenly breaking and now deprecated getZoomControls() considered
>> > private API?
>> >
>> > On Tue, Apr 28, 2009 at 6:04 PM, jharby <[email protected]> wrote:
>> >>
>> >> On Apr 15, 10:47 pm, N4Spd <[email protected]> wrote:
>> >> > I have webview whose zoom controls are placed into a linearlayout at
>> >> > the bottom of the screen.
>> >> >
>> >> > It's been working fine on 1.1 but testing on the new 1.5 beta SDK
>> >> > shows that the zoom controls are scrunched.
>> >> > They still work, just the layout is bad (buttons overlapping).
>> >> >
>> >> > I have code similar to what's been posted here:
>> >> >
>> >> > ViewGroup zoom=(ViewGroup)findViewById(R.id.zoom);
>> >> > zoom.addView(_webView.getZoomControls());
>> >> >
>> >> > The layout is also similar to what's been posted here:
>> >> >
>> >> > <RelativeLayout ...>
>> >> > <WebView.../>
>> >> > <LinearLayout android:id="@+id/zoom"
>> >> > android:layout_width="wrap_content"
>> >> > android:layout_height="wrap_content"
>> >> > android:layout_alignParentBottom="true"
>> >> > android:layout_alignParentLeft="true" />
>> >> > </RelativeLayout>
>> >> >
>> >> > thanks,
>> >> > rob
>> >>
>> >> I'm seeing that getZoomControls() is deprecated. Does anyone know the
>> >> alternative?
>> >>
>> >>
>> >
>> >
>> > >
>> >
>>
>> >>
>>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---