Search code examples
androidbackgroundgradientandroid-relativelayout

Android Q displays wrong gradient orientation


Since i updated my device to android 10 im facing a weird problem with one of my background gradients.

I have a RelativeLayout with a gradient background drawable looking like this.

<RelativeLayout
  android:id="@+id/layoutSpeedLegend"
  android:layout_width="match_parent"
  android:layout_height="18dp"
  android:background="@drawable/background"/>

My background.xml is looking like this.

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape android:shape="rectangle">

        <gradient
            android:centerColor="@color/yellow"
            android:endColor="@color/red"
            android:startColor="@color/darkgreen"
            android:centerX="50%"/>

        <corners android:radius="15dp" />
    </shape>
</item>

In the editors preview, everything looks fine enter image description here

But on my real test device is looks like this. enter image description here

Also adding android:angle="90" to my background.xml doesn't work.

Does anybody have an idea why this happens?


Solution

  • It's a bug reported here. And may not be resolved yet.

    The workaround is set angle="0" as you mentioned in question's comment.