gpt4 book ai didi

android - NestedScrollView 内的 webview 导致高度问题

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:02:45 24 4
gpt4 key购买 nike

我使用 support.v4.widget.NestedScrollView,我的 webview 有问题。

这是我的布局:

<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:focusableInTouchMode="true">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:id="@+id/barlayout">

<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:background="#9E9E9E"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|enterAlways">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/relativeLayout"
android:animateLayoutChanges="true">

<!-- some views here -->

</RelativeLayout>

</android.support.v7.widget.Toolbar>

</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_height="match_parent"
android:layout_width="match_parent" />

</android.support.v4.widget.NestedScrollView>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>

<include
android:layout_width="wrap_content"
android:layout_height="wrap_content"
layout="@layout/dialog_location"
android:id="@+id/dialog"
android:visibility="invisible"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />

</RelativeLayout>

使用这种布局,webview 必须滚动很多(抱歉链接,我不能发布图片)

https://drive.google.com/open?id=0B7otV-_1sdEvUWRzSjlHY01fY3c

如果我将 webview 更改为 wrap_content,则 webview 很小

<WebView
android:id="@+id/webView"
android:layout_height="wrap_content"
android:layout_width="match_parent" />

https://drive.google.com/open?id=0B7otV-_1sdEvbVFSRlR0a2IxeUk

最佳答案

我们正在做完全相同的事情。这已被分配给谷歌的开发人员和设计师。目前提供的解决方案是不在 NestedScrollView 中使用 Android webview。

这是线程 here 的摘录:

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.

关于android - NestedScrollView 内的 webview 导致高度问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32511882/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com