WebView and GridView into ScrollView, View too large to fit into drawing cache

余生颓废 提交于 2019-12-10 13:09:46

问题


I have a layout memory issue. When I have a large webview it doesn't shows anything and the logcat shows "View too large to fit into drawing cache".

The layout is:

<ScrollView
    android:id="@+id/scrollNoticia"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/ficha_curva" 
    android:layout_below="@+id/linea"
    android:scrollbars="none" 
    >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="12dp"

         >

        <WebView
            android:id="@+id/webViewNoticia"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scrollbars="none"

             />

        <GridView
            android:id="@+id/gridGaleria"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@id/webViewNoticia"
            android:horizontalSpacing="4dp"
            android:verticalSpacing="4dp"
            android:numColumns="4" >
        </GridView>
    </RelativeLayout>
</ScrollView>

回答1:


Neither WebView or GridView need to be embedded in a scrollview. The WebView can scroll by itself when the content size over the screen size, and the GridView too. In the normal way, the GridView just create so many child views as are visible. Once a view goes out of screen, it will be reused. So if you embed a GridView in a ScrollView, maybe you will wrong the reuse pattern.




回答2:


Try disabling the hardware acceleration : http://developer.android.com/guide/topics/graphics/hardware-accel.html

See WebView in ScrollView: "View too large to fit into drawing cache" - how to rework layout? for more informations.



来源:https://stackoverflow.com/questions/15790317/webview-and-gridview-into-scrollview-view-too-large-to-fit-into-drawing-cache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!