【问题标题】:Rendering Problems Exception raised during rendering: color and position arrays must be of equal length渲染问题 渲染过程中引发异常:颜色和位置数组必须等长
【发布时间】:2013-08-06 01:12:33
【问题描述】:

您好,我在 Android Studio 中遇到了渲染错误。有人知道这是为什么造成的吗?

我的 xml:

    <!-- ListRow Left side Thumbnail image -->

    <LinearLayout
        android:id="@+id/thumbnail"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_marginRight="5dip"
        android:background="@drawable/image_bg"
        android:padding="0dip" >

    <ImageView
         android:id="@+id/list_image"
         android:layout_width="50dip"
         android:layout_height="50dip"
         android:scaleType="centerCrop"
          />
    </LinearLayout>

    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignTop="@+id/thumbnail"
        android:layout_marginTop="0dip"
        android:layout_toRightOf="@+id/thumbnail"
        android:text="De Titel van het geweldige bericht"
        android:textColor="#60a926"
        android:textSize="15dip"
        android:textStyle="bold"
        android:ellipsize="end"
        android:typeface="sans" />

    <TextView
        android:id="@+id/subtitle"
        android:layout_width="match_parent"
        android:layout_height="25dp"
        android:layout_below="@id/title"
        android:layout_marginTop="0dip"
        android:layout_toLeftOf="@+id/imageView1"
        android:layout_toRightOf="@+id/thumbnail"
        android:text="Nieuwsbericht subtitel mooi iets ..."
        android:textStyle="bold"
        android:ellipsize="end"
        android:textColor="#9f9e9f"
        android:textSize="10dip" />


    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:src="@drawable/arrow" />

    <!-- datum van bericht -->
    <TextView
        android:id="@+id/date"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/artist"
        android:layout_alignTop="@+id/imageView1"
        android:layout_marginTop="18dp"
        android:layout_marginLeft="175dp"
        android:gravity="right"
        android:text=""
        android:textColor="#ffffff"
        android:textSize="10dip"
        android:textStyle="bold" />

</RelativeLayout>

当我使用预览时出现此错误:

"Rendering Problems Exception raised during rendering: color and position arrays must be of equal length"

这是 Android Studio 错误还是我做错了什么?

希望有人能解决。

【问题讨论】:

    标签: android android-layout listview android-studio build-tools


    【解决方案1】:

    首先禁用自动选择最佳功能。 (您可以在下图中看到)

    然后选择非预览版Api进行渲染

    就是这样,对我有用:)

    此答案还用于修复使用未更新的构建工具版本进行渲染时出现的问题。解决问题的另一种方法:

    如果您想在渲染时使用Build ToolsPreview 版本,请打开SDK Manager 并将Build Tools 版本更新为Preview Channel

    【讨论】:

      【解决方案2】:

      渐变绘图中使用的颜色必须是同一类型

      含义颜色应声明为hex 格式或attr?color xml 渐变格式。将它们混合在一起会导致此错误。

      例子

      这会崩溃

       <gradient
              android:angle="90"
              android:centerColor="@color/semi_transparent_white"
              android:endColor="@color/semi_transparent_white"
              android:startColor="?attr/colorAccent" <!--Error: Cant mix color and attr -->
              android:type="linear" />
      

      这不会

       <gradient
              android:angle="90"
              android:centerColor="@color/semi_transparent_white"
              android:endColor="@color/semi_transparent_white"
              android:startColor="@color/colorThemeAccent"
              android:type="linear" />
      

      【讨论】:

        【解决方案3】:

        我通过禁用 Android 预览版上的预览解决了这个问题。 像 Android N。

        这也有帮助

        【讨论】:

          【解决方案4】:

          我解决了。该问题是由使用错误的渐变样式文件引起的。删除渐变文件为我解决了这个问题。

          【讨论】:

            【解决方案5】:

            今天是 2015 年 4 月 14 日 (15Apr14)。 '渲染过程中出现渲染问题异常'

            这对我有用。

            我的 Android SDK 管理器已下载 19、19.1、22 和 24.1.2。 22.0.0 未列在我的 SDK 管理器中。我在 Android Studio 的“Gradle Scripts”下双击了“build.gradle (Module App)”并更改了行

            编译'com.android.support:appcompat-v7:22.0.0 为' 到 编译'com.android.support:appcompat-v7:19.1'

            然后在渲染器上方的下拉菜单中,在小 Android(称为“使用的 Android 版本...”下拉菜单,鼠标悬停)图标旁边,我选择了“API 19:Android 4.4.2”。

            渲染成功。

            以前,在同一脚本中,目标版本和构建工具版本都设置为 19:

            buildToolsVersion "19.1.0"

            targetSdkVersion 19

            【讨论】:

              猜你喜欢
              • 2016-06-25
              • 1970-01-01
              • 1970-01-01
              • 2016-10-06
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多