Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/185.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android-看似无害的布局会导致应用程序在短时间使用后崩溃,不会出现任何错误_Android_Android Layout_Android Xml - Fatal编程技术网

Android-看似无害的布局会导致应用程序在短时间使用后崩溃,不会出现任何错误

Android-看似无害的布局会导致应用程序在短时间使用后崩溃,不会出现任何错误,android,android-layout,android-xml,Android,Android Layout,Android Xml,经过两天毫无结果的测试,我决定在这里发布我的问题,希望我错过了一些明显的东西 我将一个看似无害的xml布局简化为一个随机的图像、布局和滚动视图集合。这是: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools

经过两天毫无结果的测试,我决定在这里发布我的问题,希望我错过了一些明显的东西

我将一个看似无害的xml布局简化为一个随机的图像、布局和滚动视图集合。这是:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/wood_texture"
    tools:context="com.testlayout.example.testlayout.MainActivity">

    <ImageView
        android:layout_width="150dp"
        android:layout_height="150dp"
        android:src="@drawable/image_one"
        android:id="@+id/imageOne"
        android:adjustViewBounds="true"
        android:layout_gravity="center_vertical"
        android:visibility="visible"/>

    <ImageView
        android:layout_width="300dp"
        android:layout_height="150dp"
        android:background="@drawable/dark_wood_texture"
        android:id="@+id/darkWood"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginBottom="20dp"
        android:visibility="visible"/>

    <HorizontalScrollView
        android:layout_width="300dp"
        android:layout_height="150dp"
        android:id="@+id/handScrollView"
        android:scrollbars="none"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        android:paddingTop="10dp"
        android:paddingBottom="10dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginBottom="20dp"
        android:visibility="visible">

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:id="@+id/handLayout">

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:src="@drawable/image_three"
                android:id="@+id/imageView"
                android:adjustViewBounds="true"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"/>

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:src="@drawable/image_three"
                android:id="@+id/imageView2"
                android:adjustViewBounds="true"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"/>

            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:src="@drawable/image_three"
                android:id="@+id/imageView6"
                android:adjustViewBounds="true"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="20dp"/>

        </LinearLayout>

    </HorizontalScrollView>

    <ImageView
        android:id="@+id/imageTwo"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:src="@drawable/image_two_tiled"
        android:scaleType="fitXY"/>
</RelativeLayout>
e2:我开始怀疑这是否是我手机的问题,而不是应用程序的问题,因为我可以在平板电脑上正常运行。我真的很想知道,如果其他人尝试在他们的Galaxy s6上运行此程序,是否会遇到此问题。特别是S6-这会告诉我这是我的手机还是所有S6的问题。

简而言之,是BitmapDrawable导致了整个问题。不幸的是,我无法解释为什么会解决此问题,但将使用位图的视图设置为
layerType=“software”
将防止崩溃

  • 在布局中:
    android:layerType=“software”
  • 在代码中:
    view.setLayerType(view.LAYER\u TYPE\u软件,空)

崩溃后显示的异常情况是什么?@Joshua编辑后加入了一名可能的罪犯。应用程序本身不会引发任何异常。是否解决该异常?它说你可以使用一个不存在的资源id。这是一个“神秘细菌”问题,你可以修复它,但不知道会发生什么。。我多次面对它。。好的,那么我们应该从哪里开始修复这个问题或它的rootb呢?@Joshua,我的应用程序中不存在资源id。但我也没有在任何地方引用它——这个异常是从我的应用程序外部抛出的。
E/Resources: RunTimeException
android.content.res.Resources$NotFoundException: Resource ID #0x7f0202cf
    at android.content.res.Resources.getValue(Resources.java:2558)
    at android.content.res.Resources.startRC(Resources.java:1116)
    at android.app.ActivityThread$mRunnable.run(ActivityThread.java:3056)
    at java.lang.Thread.run(Thread.java:818)