【发布时间】:2013-05-04 03:34:13
【问题描述】:
我有一个奇怪的问题,如果我尝试将 Drawable xml 文件分配给布局文件,那么应用程序会崩溃。但是,如果我改用标准颜色代码,它就可以正常工作。
注意。我几乎使用新的模板 Master/Detail Flow,我还在基本布局的 Root 视图上分配了一个 xml drawable,它工作正常。问题是将 Drawable xml 分配到列表片段的布局 (list_content.xml)
这是我的背景 xml
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:startColor="#FF000000"
android:endColor="#FF555555"
android:type="linear"
/>
</shape>
我的布局是
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_lhs"
>
<LinearLayout android:id="@+id/progressContainer"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="gone"
android:gravity="center" >
<ProgressBar style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Loading"
android:paddingTop="4dip"
android:singleLine="true" />
</LinearLayout>
<FrameLayout android:id="@+id/listContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ListView android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawSelectorOnTop="false"
/>
<TextView android:id="@+id/internalEmpty"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge" />
</FrameLayout>
</FrameLayout>
^ 在最顶部,您会找到 backgrounds 引用,当我将其更改为正常值(例如 #000000)时,它就起作用了。我也尝试过在drawable xml中使用纯色作为形状,但仍然会导致崩溃。除了Fatal signal 11 (SIGSEGV) at 0x00000004 (code=1), thread 2521,日志猫几乎没有什么帮助。没有明显的迹象可以告诉我 logcat 出了什么问题,也没有内存警告或错误。
这是请求的logcat
05-04 07:03:58.510: D/dalvikvm(1718): Not late-enabling CheckJNI (already on)
05-04 07:03:58.520: E/Trace(1718): error opening trace file: No such file or directory (2)
05-04 07:03:58.520: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:03:58.520: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:03:58.520: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:03:58.520: W/ActivityThread(1718): Application com.td3.testapp is waiting for the debugger on port 8100...
05-04 07:03:58.520: I/System.out(1718): Sending WAIT chunk
05-04 07:03:59.173: I/dalvikvm(1718): Debugger is active
05-04 07:03:59.350: I/System.out(1718): Debugger has connected
05-04 07:03:59.350: I/System.out(1718): waiting for debugger to settle...
05-04 07:03:59.560: I/System.out(1718): waiting for debugger to settle...
05-04 07:03:59.764: I/System.out(1718): waiting for debugger to settle...
05-04 07:03:59.970: I/System.out(1718): waiting for debugger to settle...
05-04 07:04:00.173: I/System.out(1718): waiting for debugger to settle...
05-04 07:04:00.383: I/System.out(1718): waiting for debugger to settle...
05-04 07:04:00.594: I/System.out(1718): waiting for debugger to settle...
05-04 07:04:00.800: I/System.out(1718): waiting for debugger to settle...
05-04 07:04:01.013: I/System.out(1718): debugger has settled (1362)
05-04 07:04:01.013: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.013: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.040: D/dalvikvm(1718): GC_FOR_ALLOC freed 94K, 8% free 2508K/2720K, paused 1ms, total 2ms
05-04 07:04:01.071: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.090: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.100: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.100: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.120: D/libEGL(1718): loaded /system/lib/egl/libEGL_emulation.so
05-04 07:04:01.120: D/(1718): HostConnection::get() New Host Connection established 0xb9518330, tid 1718
05-04 07:04:01.140: D/libEGL(1718): loaded /system/lib/egl/libGLESv1_CM_emulation.so
05-04 07:04:01.140: D/libEGL(1718): loaded /system/lib/egl/libGLESv2_emulation.so
05-04 07:04:01.201: W/EGL_emulation(1718): eglSurfaceAttrib not implemented
05-04 07:04:01.220: D/OpenGLRenderer(1718): Enabling debug mode 0
05-04 07:04:01.220: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.231: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.231: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.231: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.231: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.241: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.241: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.241: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.241: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.241: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.241: W/Trace(1718): Unexpected value from nativeGetEnabledTags: 0
05-04 07:04:01.251: A/libc(1718): Fatal signal 11 (SIGSEGV) at 0x00000004 (code=1), thread 1718 (.td3.testapp)
【问题讨论】:
-
投反对票的人需要停止拖钓,它变老了
-
发布您的 logcat 跟踪...
-
渐变上的一些东西让我觉得“奇怪”:属性
android:dither不应该存在,因为它只适用于位图数据,不适用于动态生成的可绘制对象。此外,半径为0的radial渐变听起来也不对。尝试设置一个正(浮点)值。 -
很抱歉对 xml 的误解,但代码实际上是从以前的线性渐变中复制的,但在对崩溃进行排序之前,我从未费心修复值。但就像我说的,我也尝试了一个具有 1 个属性的简单实心形状......颜色
-
投反对票?说真的,你真的认为这个问题很糟糕。请阅读常见问题解答先生。
标签: android android-layout android-emulator android-drawable