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

风流意气都作罢 提交于 2019-12-19 18:15:25

问题


Hello i'm getting rendering errors in Android studio. Does someone know why this is caused?

My 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>

When i'm using the Preview i'm getting this error:

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

Is this an Android Studio bug or i am doing something wrong ?

I hope someone has the solution.


回答1:


Firstly disable Automatically pick best feature. (You can see on below image)

Then select non preview Api version for rendering

Thats all and worked for me :)

Also this answer given for fixing problems when using non updated Build Tools Version for rendering. Another way to fix problem :

Open SDK Manager and update Build Tools version to Preview Channel if you want to use Preview version of Build Tools when rendering.




回答2:


I solved this issue by disabeling the preview on a preview version of Android. Like Android N.

This also helps




回答3:


I solved it. The problem was caused by using a false gradient style file. Deleting the gradient file solved the problem for me.




回答4:


Today is April 14, 2015 (15Apr14). 'Rendering problems exception raised during rendering'

Here's what worked for me.

My Android SDK manager has downloaded 19, 19.1, 22, and 24.1.2. 22.0.0 is not listed in my SDK manager. I double clicked 'build.gradle (Module App) under 'Gradle Scripts' in Android Studio and changed the line

compile 'com.android.support:appcompat-v7:22.0.0 to ' to compile 'com.android.support:appcompat-v7:19.1'

Then in the drop down menu above the renderer , next to the little Android (called 'Android version to use ...' drop down menu with mouseover) icon I selected 'API 19: Android 4.4.2'.

Rendering worked.

Previously, in the same script target version and build tool versions were set to 19:

buildToolsVersion "19.1.0"

targetSdkVersion 19




回答5:


Colors used in Gradient Drawable must be of same type

Meaning colors should be declared as either hex format or attr?color format in gradient of xml. Mixing them together cause this error.

Example

This will crash

 <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" />

This wont

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


来源:https://stackoverflow.com/questions/18056303/rendering-problems-exception-raised-during-rendering-color-and-position-arrays

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!