Reputation: 123
I have following xml for GradientDrawable. How can I change the angle programmatically?
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:type="linear"
android:angle="45"
android:startColor="#FF0000"
android:endColor="#00FF00" />
</shape>
Upvotes: 12
Views: 7390
Reputation: 51
Try:
GradientDrawable appTheme = new GradientDrawable(GradientDrawable.Orientation.BL_TR, colors);
Upvotes: 3
Reputation: 4222
GradientDrawable has a method called: .setOrientation(GradientDrawable.Orientation orientation)
, you can change the orientation of a gradient with this. You need to inflate the XML as GradientDrawable.
Upvotes: 14