小编onu*_*pus的帖子

webview height在nestedScrollView中无限增长

这是我的布局.当我加载google.com时,webview的高度会无限增长.webview的onSizeChange函数不断被调用,我可以看到webview不断无限扩展.我已经尝试了22.2.1和23.1.0的设计和appcompat库并没有效果.

有解决方案吗 : - |

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black">

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

    <com.example.ajay.scrollabletoolbar.MyWebView
        android:id="@+id/webview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"/>
</android.support.v4.widget.NestedScrollView>

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

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

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#FFFFFF"
            android:descendantFocusability="beforeDescendants"
            android:focusableInTouchMode="true">

            <EditText
                android:id="@+id/current_url"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_centerVertical="true"
                android:backgroundTint="@android:color/darker_gray"
                android:dropDownAnchor="@+id/restricted_browser_toolbar"
                android:hint="hint hint"
                android:imeOptions="actionGo|flagNoExtractUi"
                android:inputType="textNoSuggestions|textUri"
                android:paddingBottom="8dp"
                android:paddingEnd="8dp"
                android:paddingStart="8dp"
                android:singleLine="true"/>

            <ImageView
                android:id="@+id/clear_url_text"
                android:layout_width="48dp"
                android:layout_height="48dp"
                android:layout_alignRight="@+id/current_url"
                android:layout_centerVertical="true"
                android:layout_marginRight="8dp"
                android:src="@android:drawable/ic_menu_close_clear_cancel"
                android:visibility="gone"/>
        </RelativeLayout>
    </android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
Run Code Online (Sandbox Code Playgroud)

android webview android-coordinatorlayout android-collapsingtoolbarlayout nestedscrollview

10
推荐指数
1
解决办法
3884
查看次数

recyclerview中的Webview不会扩展到位.(不缩小底部)

我正在研究类似于'谷歌收件箱'的东西,这需要我在recyclerView中有多个webview,我可以通过点击标题来扩展和折叠内容,这将添加/删除标题下的webview.

到目前为止,这是该项目的要点

Fragment
 -> RecyclerView (match_parent on height and width)
   -> Adapter + ViewModel/Model
     -> XML + Databinding.
Run Code Online (Sandbox Code Playgroud)

XML结构

LinearLayout (vertical)
 -> Header (match_parent on width, wrap_content on height)
 -> WebView (match_parent on width, wrap_content on height) 
(Webview does not scroll and it scales with the contents.
 the recyler view handles scrolling)
Run Code Online (Sandbox Code Playgroud)

默认情况下,所有Web视图的可见性都消失了,当用户第一次点击标题时,调用webview.loadDataWithBaseUrl()时会加载它应该加载的内容并打开可见性.webview缩放其高度以完全显示内容.当用户再次单击标题时,它会将可见性变为已消失,整个行将折叠为标题.再次单击先前展开的标题,我不必再次加载数据,而只是打开可见性.

一切都很有效,但对于这个非常讨厌的问题. https://nofile.io/f/UBCh5PO7Wv9/screencapture-1525973579493.mp4这是Google收件箱中的录音和我的应用程序有完全相同的问题.

当我点击标题进行扩展并在webview中加载内容时,一些webview会在下面展开,我的意思是标题保持不变,看起来内容加载在点击的标题下方.

但对于某些内容,webviews会向上扩展,这意味着它会推动单击的标题以展开内容.这意味着我在看内容的结尾而不是顶部.就像收件箱的这种情况一样,我正在查看电子邮件的结尾,但不是在电子邮件的顶部.

我在我分享的视频中复制了电子邮件的来源,并使用它们加载我的网页视图,这是我的发现.

  • 它与加载的内容无关,因为即使我混淆了它也会发生
  • 它与webview的计数或给定webview的索引无关
  • 如果我将内容从上到下展开,就不会发生这种情况.意思是从索引0..n - >但是但它总是发生在我把所有东西都折叠起来并且我从下到上扩展内容......从n到0.

在此输入图像描述

基本上,如果A和B是webview的顶部和底部边缘,理想情况下A应该保持稳定,B应该增加向下推动它下面的recyclerView内容.但相反,当我从下向上扩展内容时,底线B保持稳定并且webview增加并推动标题和给定行上方的项目以及它导致查看结束时的恼人行为内容比谷歌收件箱中的顶部更好.

这是一个发生什么的gif - 当我点击紫色标题时,webview(粉红色)加载电子邮件.当我点击最后一个时,webview将在下面展开.但是当我点击最后一个时,它会向上扩展,然后向上推动标题.

有什么想法吗?救命?

谢谢

html android android-webview recycler-adapter android-recyclerview

9
推荐指数
1
解决办法
473
查看次数

Android中的发布与调试构建差异

总而言之,我们面临一个奇怪的问题,即我们的应用程序在调试版本变体中运行良好.但它无法在发布版本变体上正确执行.甚至奇怪的是,如果我们为发布版本变体设置debuggable为true,它可以正常工作.两种变体都禁用了Proguard.

我试图了解android中的发布和调试版本变体之间的区别.你能指点我帮助我理解差异的任何资源吗?

谢谢

以下作品.但是如果我删除了debuggable,它就无法正常工作.调试构建始终有效.

buildTypes {
    release {
        debuggable true
        signingConfig signingConfigs.release
    }
    debug {
        signingConfig signingConfigs.debug
    }
}
Run Code Online (Sandbox Code Playgroud)

android android-studio

6
推荐指数
1
解决办法
2440
查看次数