изменить цвет Graintint в клипе в drawable.xml - PullRequest
0 голосов
/ 23 сентября 2018

в этом раскладном макете.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@android:id/background">
        <shape android:shape="line">
            <stroke
                android:width="2dp"
                android:color="@color/lightGray"
                android:dashGap="10dp"
                android:dashWidth="45dp" />
        </shape>
    </item>
    <item android:id="@android:id/progress" >
        <clip >
            <shape android:shape="rectangle" >
                <size android:height="5dp"/>
                <corners android:radius="5dp" />
                <gradient
                    android:endColor="@color/green"
                    android:startColor="@color/colorPrimary" />
            </shape>
        </clip>
    </item>
</layer-list>

Мне нужно изменить текущий градиент цвета.

для идентификатора фона, я могу изменить цвет с помощью этого кода:

 val seekBarDrawable = ContextCompat.getDrawable(context, R.drawable.seek_bar_progress)
 val seekBarDrawableLayerDrawable = seekBarDrawable as LayerDrawable
 val ovalItem = seekBarDrawableLayerDrawable.findDrawableByLayerId(R.id.background) as GradientDrawable

        ovalItem.colors = intArrayOf(Color.RED, Color.GREEN)
        ovalItem.gradientType = GradientDrawable.LINEAR_GRADIENT

, но для идентификатора прогресса, форма в клипе, как изменить цветовой градиент в клипе?

...