I use a selector list to pick a buttons background.
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_enabled="false"
android:drawable="@drawable/shapecopmainbutton" />
<item
android:state_pressed="true"
android:state_enabled="true"
android:drawable="@drawable/shapecopmainbuttonpress" />
<item
android:state_focused="true"
android:state_enabled="true"
android:drawable="@drawable/shapecopmainbutton" />
<item
android:state_enabled="true"
android:drawable="@drawable/shapecopmainbutton" />
</selector>
my shapecopmainbutton.xlm is as follows.
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="oval">
<size
android:width="@dimen/layoutwidthMaincopbutton"
android:height="@dimen/HeightMaincopbutton" />
<solid android:color="@color/black"/>
</shape>
</item>
<item
android:id="@+id/gradientDrawble"
android:left="4dp"
android:right="1dp"
android:top="0dp"
android:bottom="5.5dp"
>
<shape
android:id="@+id/gradientDrawbles"
android:shape="ring"
android:thickness="@dimen/thicknessMaincopbutton"
android:innerRadius="@dimen/innerRadiusMaincopbutton"
android:useLevel="false">
<solid android:color="@color/GradientEnd" />
<gradient
android:id="@+id/gradientDrawbleg"
android:type="radial"
android:gradientRadius="30%p"
android:startColor="@color/GradientCenter"
android:endColor="@color/GradientEnd"
android:centerX="0.2"
android:centerY="0.2"
/>
</shape>
</item>
I want to change the start and end color of the gradient attribute of the ring shape.
this is what I have so far in my code:
EDited.
StateListDrawable stateListDrawable=(StateListDrawable) ContextCompat.getDrawable(context,R
.drawable.copbuttonmaineffect);
LayerDrawable layerDrawable = (LayerDrawable) stateListDrawable.getCurrent();
int colors[] = { R.color.GradientStartl, R.color.GradientEndl };
GradientDrawable gradientDrawable = (GradientDrawable) layerDrawable.findDrawableByLayerId(R.id.
gradientDrawble);
gradientDrawable.setColors(colors);
I stumped here as I'm not able to figure out how to set the 'rings' start/stop color gradient attribute.
thanks.