WAI
Status Update
Comments
st...@gmail.com <st...@gmail.com> #2
You can see that the webview height is the full height of the site content. With behaviour the webview cant get the current scroll position. For the javascript onscrolllistener i have a workaround posted on stackoverflow:
http://stackoverflow.com/questions/34788313
st...@gmail.com <st...@gmail.com> #3
Another problem is that you cant positioning a element as a footer or header because the viewport of the WebView isnt correct. I wish Google will change this.
am...@google.com <am...@google.com>
am...@google.com <am...@google.com> #4
Hi,
please attach your sample project which reproduces the issue, zip it and share.
explain expected and observed behavior? Attach screen shots for more clarity.
Which device the issue observed on?
Explain the steps to reproduce the issue with your apk.
Note: Please upload the attachments to google drive and share the folder to android-bugreport@google.com, then share the link here.
please attach your sample project which reproduces the issue, zip it and share.
explain expected and observed behavior? Attach screen shots for more clarity.
Which device the issue observed on?
Explain the steps to reproduce the issue with your apk.
Note: Please upload the attachments to google drive and share the folder to android-bugreport@google.com, then share the link here.
st...@gmail.com <st...@gmail.com> #5
Hi,
i have uploading a sample app to reproduce the issue.
https://drive.google.com/file/d/0B_2jFRN7HVpZYWhqbU5vZlJrWDA/view
The expected behaviour is, that the webview height is only maximal large as the screen size.
The issue is, that the webview height is the height of the content of the loaded page.
I can reproduce the issue on sereral devices like Nexus 5 with Android 6 or HTC M9 with Android 5.
You can reproduce the issue:
- Install the app
- Open in chrome: chrome://inspect
- You can see in the preview of the screen, that the webview has the full height of the content
If you comment out the NestedScrollView in the activity_main.xml, the webview height has the max height of the screen.
I hope that you understand what the problem is.
The behaviour is very ugly, because you cant set a scrollistener in javascript or positioning a div absolute.
Best regards,
Steffen
i have uploading a sample app to reproduce the issue.
The expected behaviour is, that the webview height is only maximal large as the screen size.
The issue is, that the webview height is the height of the content of the loaded page.
I can reproduce the issue on sereral devices like Nexus 5 with Android 6 or HTC M9 with Android 5.
You can reproduce the issue:
- Install the app
- Open in chrome: chrome://inspect
- You can see in the preview of the screen, that the webview has the full height of the content
If you comment out the NestedScrollView in the activity_main.xml, the webview height has the max height of the screen.
I hope that you understand what the problem is.
The behaviour is very ugly, because you cant set a scrollistener in javascript or positioning a div absolute.
Best regards,
Steffen
ca...@instantbits.com <ca...@instantbits.com> #6
I haven't tested #5 but his images do show the same issue. Here are my screenshots and zip file. All I did is create the template scrolling activity on Android Studio and added a WebView to it.
Also on my zip if you uncomment
//view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
you will see the crash that I'm guessing is happening because of the same issue.
Also on my zip if you uncomment
//view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
you will see the crash that I'm guessing is happening because of the same issue.
am...@google.com <am...@google.com> #7
Hi,
checked the issue on nexus 6 and 5 with 6.0.1. not observing the wrong behavior which you are observing.
Attached are the screenshots I am observing, please put your comments for the same.
checked the issue on nexus 6 and 5 with 6.0.1. not observing the wrong behavior which you are observing.
Attached are the screenshots I am observing, please put your comments for the same.
st...@gmail.com <st...@gmail.com> #8
If you add a LayoutChangeListener to the webview you can see that the height is not correct.
wvTest.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
Log.i("NSVWebView", "WebView Height: " + wvTest.getHeight());
}
});
In the LogCat you can see the following results:
-With NestedScrollView
WebView Height: 17553
-Without NestedScrollView
WebView Height: 1437
You can see that the WebView height increased if the webview is in the NestedScrollView.
wvTest.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
Log.i("NSVWebView", "WebView Height: " + wvTest.getHeight());
}
});
In the LogCat you can see the following results:
-With NestedScrollView
WebView Height: 17553
-Without NestedScrollView
WebView Height: 1437
You can see that the WebView height increased if the webview is in the NestedScrollView.
am...@google.com <am...@google.com> #9
Hi,
We have passed this defect on to the development team and will update this issue with more information as it becomes available.
Thanks
We have passed this defect on to the development team and will update this issue with more information as it becomes available.
Thanks
am...@google.com <am...@google.com> #10
This is WAI.
If you put webview in a NestedScrollView, height is wrap_contents, and the webview expands to the size of the page. This is as if in desktop, you resize the browser window to height of the page so it can't scroll vertically. The scrolling is happening in NestedScrollView rather than webview itself.
So a consequence of no js in the page sees any scroll events, so it doesn't know you've scrolled to the end of the page load more content.
Also hardware layers is backed by GL textures, and they have a maximum size (which is least the screen size, although usually not much bigger). If a view becomes larger than the maximum texture size, then it won't work with a hardware layer. This applies to any view, not just webview.
Solution: don't put webview in a NestedScrollView. don't use webview in wrap_contents mode. Let webview scroll the web page itself.
If you put webview in a NestedScrollView, height is wrap_contents, and the webview expands to the size of the page. This is as if in desktop, you resize the browser window to height of the page so it can't scroll vertically. The scrolling is happening in NestedScrollView rather than webview itself.
So a consequence of no js in the page sees any scroll events, so it doesn't know you've scrolled to the end of the page load more content.
Also hardware layers is backed by GL textures, and they have a maximum size (which is least the screen size, although usually not much bigger). If a view becomes larger than the maximum texture size, then it won't work with a hardware layer. This applies to any view, not just webview.
Solution: don't put webview in a NestedScrollView. don't use webview in wrap_contents mode. Let webview scroll the web page itself.
ca...@instantbits.com <ca...@instantbits.com> #11
Thanks for the reply #10. So does this mean then that Google recommends against using the coordinator layout to collapse and expand the toolbar on WebView scroll?
to...@gmail.com <to...@gmail.com> #12
I discovered the same issue and since WebViews shouldn't be embedded in a NestedScrollView (like mentioned in #10), I think the Design Support Library should provide a WebView Wrapper that implements NestedScrollingChild. In this way WebViews could be used with CoordinatorLayouts.
I submitted a feature request (https://code.google.com/p/android/issues/detail?id=200394 ) and provided a workaround (https://github.com/rhlff/NestedScrollWebView ).
I submitted a feature request (
ca...@instantbits.com <ca...@instantbits.com> #13
#12 cool solution but it doesn't work perfectly. When loading vimeo.com it collapsed the bar kinda jerky when scrolling fast, also it stopped collapsing after the first time I expanded it again. I also had scrolling freeze a few times. Despite all this I think you are on the right path, implementing NestedScrollingChild is probably the correct way to do this.
sh...@gmail.com <sh...@gmail.com> #14
We have the exact same issue, which is a real project killer...
especially since it was working OK in 4.2.2 but for some reason it's totally unusable in 4.4 and above.
We've tried #12 implementation which resolves a few problems but is far to be as smooth as the original nestedscrollview(thank you for the hard work though!).
Would really like to get this worked out...
especially since it was working OK in 4.2.2 but for some reason it's totally unusable in 4.4 and above.
We've tried #12 implementation which resolves a few problems but is far to be as smooth as the original nestedscrollview(thank you for the hard work though!).
Would really like to get this worked out...
ca...@instantbits.com <ca...@instantbits.com> #15
[Comment deleted]
ca...@instantbits.com <ca...@instantbits.com> #16
Sadly Google has said the WebView is not supported by the support tools on this issue 36949180
sh...@gmail.com <sh...@gmail.com> #17
[Comment deleted]
sh...@gmail.com <sh...@gmail.com> #18
This is not the kind of answer I would expect from a Google team.
The support library should support, not throw at us new problems...
If #12 has almost been able to do it, it is certainly not an irreversible problem right?
What's the reason to not fix the bug?
(if it works in 4.2, it should work in 4.4)
The support library should support, not throw at us new problems...
If #12 has almost been able to do it, it is certainly not an irreversible problem right?
What's the reason to not fix the bug?
(if it works in 4.2, it should work in 4.4)
ca...@instantbits.com <ca...@instantbits.com> #19
Well 4.4 changed the WebView completely. But actually I had issues with the NestedScrollView and the WebView on < 4.4 as well, just not as many issues.
sh...@gmail.com <sh...@gmail.com> #20
True, it was not perfect in 4.2 but bearable.
but saying it works as expected seems a bit of a stretch...
We've noticed that the height is ok when we use a fragment combined with a tab at the bottom but we need to try this out with other screens.
I hope they will fix that as it is certainly a very common use case.
but saying it works as expected seems a bit of a stretch...
We've noticed that the height is ok when we use a fragment combined with a tab at the bottom but we need to try this out with other screens.
I hope they will fix that as it is certainly a very common use case.
[Deleted User] <[Deleted User]> #21
Using the code from NestedScrollView I have implemented a custom WebView. In my case is working as expected with the coordinator layout.
Include
<com.tuenti.NestedScrollWebView
android:id="@+id/wv_web"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
directly inside you coordinatorLayout without using NestedScrollView.
I agree with you, Google should include a solution to support the use of WebView widget inside a coordinatorLayout.
https://gist.github.com/alexmiragall/0c4c7163f7a17938518ce9794c4a5236
Include
<com.tuenti.NestedScrollWebView
android:id="@+id/wv_web"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
directly inside you coordinatorLayout without using NestedScrollView.
I agree with you, Google should include a solution to support the use of WebView widget inside a coordinatorLayout.
[Deleted User] <[Deleted User]> #22
[Comment deleted]
el...@gmail.com <el...@gmail.com> #23
I have implemented another version of a custom NestedScrollView. Like that posted in comment #21 , this implements the NestedScrollingChild directly. It can be used as a sibling of AppBarLayout or as a child of SwipeRefreshLayout.
It is released under the GPLv3+ and is available athttps://git.stoutner.com/?p=PrivacyBrowser.git;a=blob;f=app/src/main/java/com/stoutner/privacybrowser/views/NestedScrollWebView.java;hb=HEAD
It is released under the GPLv3+ and is available at
Description
Theme used: Theme.AppCompat.Light.DarkActionBar
Devices/Android versions reproduced on: 6.0.1, 5.1, 4.4, 4.2.2 (not as bad)
Basically the WebView inside a NestedScrollView doesn't work properly when using sites that want to continuously load more content as you scroll to the end of the page. It is as if the site can't detect that it is at the end of the page. Also scroll continues beyond the page on Android 4.4+, on 4.2.2 it seems to stop near the bottom.
Also probably related to this issue, if you enable this line view.setLayerType(View.LAYER_TYPE_HARDWARE, null); then the app crashes because OpenGL thinks the surface is larger than the maximum. Neither problem happens without NestedScrollView.
Here is my layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="
xmlns:app="
xmlns:tools="
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.webviewtesthw.ScrollingActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested"
xmlns:android="
xmlns:app="
xmlns:tools="
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.webviewtesthw.ScrollingActivity"
tools:showIn="@layout/activity_scrolling"
>
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="match_parent"></WebView>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/fab_margin"
android:src="@android:drawable/ic_dialog_email"
app:layout_anchor="@id/app_bar"
app:layout_anchorGravity="bottom|end"/>
</android.support.design.widget.CoordinatorLayout>
And the actvity:
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class ScrollingActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scrolling);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
WebView view = (WebView) findViewById(R.id.webview);
view.setWebViewClient(new WebViewClient());
WebSettings settings = view.getSettings();
settings.setJavaScriptEnabled(true);
settings.setAllowContentAccess(true);
settings.setAppCacheEnabled(true);
settings.setDatabaseEnabled(true);
settings.setDomStorageEnabled(true);
settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setBuiltInZoomControls(true);
settings.setAppCacheEnabled(true);
settings.setAppCachePath(getCacheDir().getAbsolutePath());
settings.setDatabaseEnabled(true);
settings.setSupportMultipleWindows(true);
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
settings.setDomStorageEnabled(true);
settings.setAllowContentAccess(true);
settings.setAllowFileAccess(true);
settings.setSaveFormData(true);
// findViewById(R.id.nested).setLayerType(View.LAYER_TYPE_HARDWARE, null);
// view.setLayerType(View.LAYER_TYPE_HARDWARE, null);
view.loadUrl("
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_scrolling, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
//noinspection SimplifiableIfStatement
if (item.getItemId() == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}