What I am trying to accomplish:
int[] colors = new int[]{colorDark,colorLight}
GradientDrawable gd = new GradientDrawable(TOP_BOTTOM, colors);
remoteView.setBackgroundDrawable(gd); //method does not exist
Obviously this is not possible.
How can I accomplish this? (if it's possible)
I do not want to have to create multiple shapes in xml files for different colors, because this limits options.
I have tried converting my drawable to a bitmap and calling setImageViewBitmap
. I converted with this code and used this code to get the width/height, but I'm unable to get the widget to be filled (additionally, the device's display width/height really aren't what I need anyway)
I am just guessing. Can you try to extend RemoteViews and override the apply function:
public class MySpecialRemoteViews extends RemoteViews {
//add the Constructors
public View apply(Context context, ViewGroup parent) {
View result = super.apply(context, parent);
//your code
int[] colors = new int[]{colorDark,colorLight}
GradientDrawable gd = new GradientDrawable(TOP_BOTTOM, colors);
result.setBackgroundDrawable(gd);
//end of your code
return result;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With