简体   繁体   English

android - CoordinatorLayout / NestedScrollView /隐藏 - 显示工具栏/ WebView问题

[英]android - CoordinatorLayout/NestedScrollView/Hide-Show Toolbar/Issue with WebView

I have a problem with that : 我有一个问题:

<?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.CoordinatorLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/coordinatorLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appBarLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            app:layout_scrollFlags="scroll|enterAlways" />
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior">

        <WebView
            android:id="@+id/webView"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </android.support.v4.widget.NestedScrollView>

</android.support.design.widget.CoordinatorLayout>

When I scrolls in the webview, the toolbar is hidden or shown (perfect !) but there is a problem with the loading / positioning web pages. 当我在webview中滚动时,工具栏被隐藏或显示(完美!)但是加载/定位网页时出现问题。 For example, if I scrolls to the middle of a page and I click on a link, the new page that will load also be located at approximately the middle of the page instead of on top. 例如,如果我滚动到页面的中间并单击链接,则将加载的新页面也位于页面的大约中间而不是顶部。 As if scrollbars were not moving from one page to another. 好像滚动条没有从一个页面移动到另一个页面。

if I add to the NestedScrollView: 如果我添加到NestedScrollView:

android:fillViewport="true"

everything works with the webview (pages load and appear well although starting from the top) but I lose the Hide/Show with the toolbar :( 一切都适用于webview(页面加载并显示良好,虽然从顶部开始)但我丢失隐藏/显示与工具栏:(

Do you have any idea about this problem? 你对这个问题有什么看法吗?

Thank you in advance for your help :) 预先感谢您的帮助 :)

(For information : Android Design Support Library : 23.0.1) (有关信息:Android设计支持库:23.0.1)

Yop

My assumption: Since you are putting the WebView inside a NestedScrollView the scrolling is not done on the WebView level so when you load a new page the NestedScrollView stays in the same position. 我的假设:由于您将WebView放在NestedScrollView ,因此在WebView级别上不会进行滚动,因此当您加载新页面时, NestedScrollView保持在相同的位置。

Suggestion: create a WebViewClient and override onPageStarted here you should change the NestedScrollView scroll position to 0: 建议:创建WebViewClient并覆盖onPageStarted ,您应该将NestedScrollView滚动位置更改为0:

nestedScrollView.scrollTo(0, 0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有NestedScrollView的Android CoordinatorLayout不会折叠工具栏 - Android CoordinatorLayout with NestedScrollView not collapsing the toolbar CoordinatorLayout(Toolbar + NestedScrollView + BottomNavigationView)问题 - CoordinatorLayout (Toolbar+NestedScrollView+BottomNavigationView) issue 在CoordinatorLayout上以编程方式隐藏/显示工具栏 - Hide/Show Toolbar programmatically on CoordinatorLayout CoordinatorLayout内NestedScrollView内的webview不竞争显示内容 - webview inside NestedScrollView inside CoordinatorLayout do not show content competely NestedScrollView和CoordinatorLayout。 滚动问题 - NestedScrollView and CoordinatorLayout. Issue on Scrolling 使用CoordinatorLayout滚动隐藏工具栏 - Hide Toolbar on scroll with CoordinatorLayout Android NestedScrollView在CoordinatorLayout中平滑滚动 - Android NestedScrollView smooth scroll in CoordinatorLayout NestedScrollView 不在 CoordinatorLayout 内滚动 - Android - NestedScrollView not scrolling inside CoordinatorLayout - Android 在NestedScrollView Android 2.3或更低版本中滚动WebView - Issue scrolling WebView in NestedScrollView Android 2.3 or less 显示/隐藏webview问题 - Show/Hide webview issue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM