0

我决定根据屏幕的尺寸和密度来分开布局。normal-ldpi 中的文件不起作用 small-ldpi 其他文件夹中的其他文件都很好。

这是我的文件中的错误:

Exception raised during rendering: Index: 1, Size: 1
Exception details are logged in Window > Show View > Error Log

在 ErrorLog 我有:

java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
    at java.util.ArrayList.rangeCheck(Unknown Source)
    at java.util.ArrayList.get(Unknown Source)
    at com.android.ninepatch.NinePatchChunk.draw(NinePatchChunk.java:174)
    at com.android.ninepatch.NinePatchChunk.draw(NinePatchChunk.java:101)
    at android.graphics.NinePatch_Delegate$1.draw(NinePatch_Delegate.java:219)
    at com.android.layoutlib.bridge.impl.GcSnapshot.drawInLayer(GcSnapshot.java:608)
    at com.android.layoutlib.bridge.impl.GcSnapshot.draw(GcSnapshot.java:577)
    at android.graphics.NinePatch_Delegate.draw(NinePatch_Delegate.java:217)
    at android.graphics.NinePatch_Delegate.nativeDraw(NinePatch_Delegate.java:170)
    at android.graphics.NinePatch.nativeDraw(NinePatch.java)
    at android.graphics.NinePatch.draw(NinePatch.java:104)
    at android.graphics.drawable.NinePatchDrawable.draw(NinePatchDrawable.java:188)
    at android.view.View.draw(View.java:6725)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
    at android.view.View.draw(View.java:6743)
    at android.view.ViewGroup.drawChild(ViewGroup.java:1640)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1367)
    at android.view.View.draw(View.java:6743)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:466)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:320)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:325)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:440)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1545)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1302)

我使用 API Level 8,它应该可以工作,不是吗?

这里是上面报错对应的xml文件

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/layout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:weightSum="10"
    android:orientation="vertical"
    android:background="@drawable/fond">

    <ImageView
         android:id="@+id/imageView9"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:layout_weight="2"
         android:scaleType="fitXY"
         android:src="@drawable/bandeau" />

    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/layout2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="6"
        android:background="@drawable/fondshare"
        android:gravity="center"
        android:orientation="vertical"
        android:weightSum="3" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:weightSum="2"
            android:layout_gravity="center" 
            android:layout_marginTop="10dp"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/imageView5"
                android:layout_width="fill_parent"
                android:layout_height="match_parent"
                android:adjustViewBounds="true"
                android:src="@drawable/cadre" />

            <ImageView
                android:id="@+id/imageView8"
                android:layout_width="fill_parent"
                android:layout_height="match_parent"
                android:adjustViewBounds="true"
                android:src="@drawable/niceshot" />

        </LinearLayout>

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            android:weightSum="5"
            android:layout_gravity="center" 
            android:layout_marginLeft="20dp"
            android:layout_marginRight="20dp"
            android:layout_marginBottom="10dp"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/imageView7"
                android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:adjustViewBounds="true"
                android:src="@drawable/enterthename" />

            <EditText
                android:id="@+id/editText1"
                android:layout_weight="1"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_marginTop="4dp" />

            <ImageView
                android:id="@+id/imageView2"
                android:layout_weight="1"             
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_marginTop="4dp"
                android:adjustViewBounds="true"
                android:src="@drawable/sharefacebook" />

            <ImageView
                android:id="@+id/imageView3"
                android:layout_weight="1"             
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_marginTop="4dp"
                android:adjustViewBounds="true"
                android:src="@drawable/sharetwitter" />

            <ImageView
                android:id="@+id/imageView6"
                android:layout_weight="1"            
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_marginTop="4dp"
                android:adjustViewBounds="true"
                android:src="@drawable/sharefacebook" />

        </LinearLayout>
     </LinearLayout>

     <ImageView
         android:id="@+id/imageView10"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:layout_weight="2"
         android:scaleType="fitEnd"
         android:src="@drawable/dim" />

</LinearLayout>
4

1 回答 1

2

我遇到了同样的问题,我通过更新我的 SDK 管理器解决了这个问题,即以前我在我的 Eclipse 中安装了最高 4.0.3(API 15)的 SDK ......我安装了最新版本 4.1.2(API 16)并且错误消失了. 实际上,这是以前库中的一个错误,已在 API 16 版本中解决。

于 2013-08-22T11:24:53.350 回答