1

I want to change the widget background opacity, which is defined by a drawable including a color code, programmatically in the onEnabled method.

This is the drawable:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <corners android:radius="5dp"/>
    <solid android:color="#FFFFFF"/>
</shape>

I want to change the color opacity programmatically, how can I do that? I already tried using:

Drawable drawable = getResources().getDrawable(R.drawable.widget_shape);
drawable.setAlpha(80);

But without success

qwertz
  • 6,206
  • 9
  • 40
  • 62

0 Answers0