I have a custom ViewGroup, It does only one thing, changing background's alpha on layout phase:
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
...
getBackground().setAlpha(0);
...
}
print alpha in setBackground
:
@Override
public void setBackground(Drawable background) {
if (background instanceof ColorDrawable) {
bgAlpha = Color.alpha(((ColorDrawable) background).getColor());
d("bg:" + Integer.toHexString(bgAlpha));
super.setBackground(background);
} else {
...
}
}
Now I have a activity inflate this custom view from layout xml:
<CustomViewGroup
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#88000000" />
When I first launch the app, setBackground
print:
bg:88
then I finish the app and reopen it from launcher, setBackground
print:
bg:0
Why background drawable retain its state after activity finished?