I have a homescreen widget, with linear layout. I'm trying to set Alpha for the background during runtime using remote views, but the widget doesn't load.
I'm using this:
remoteView.setFloat(R.id.widget_background, "setAlpha", (float)0.7);
Setting background color or text color the same way, works. How can I set the background transparency using remote views?
There is a simple solution using background color in hex. You have a color, for example RED - #ff0000
to set background red to your app widget, you can use:
widget.setInt(R.id.widget_list, "setBackgroundColor", Color.parseColor("#ff0000"));
for color transparency just add in front of your color how much color - transparency rapport you want, for example:
for 20% color will be #20ff0000:

for 85% color #85ff0000 wou'll have:

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