8

您好,我在 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错误还是我做错了什么?

我希望有人有解决方案。

4

5 回答 5

16

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

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

就是这样,为我工作:)

在此处输入图像描述

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

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

于 2016-04-17T12:32:54.030 回答
5

Gradient Drawable 中使用的颜色必须是相同的类型

意思是颜色应该被声明为xml 渐变中的hex格式或attr?color格式。将它们混合在一起会导致此错误。

例子

这会崩溃

 <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" />
于 2019-09-09T14:47:33.017 回答
3

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

于 2013-08-05T13:19:53.920 回答
3

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

这也有帮助

于 2016-04-17T11:52:27.713 回答
2

今天是 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:

构建工具版本“19.1.0”

targetSdkVersion 19

于 2015-04-14T16:07:27.567 回答