Is it possible in android to set up a view in a way that it applies some color filter to everything below that's visible in its bounds? Like in this example:
Just a simple rectangular view that inverts colors of everything below it. Of course when user scrolls the list it is also reflected in the inverted box. Is there some easy way to do it using color filters, PorterDuff modes, etc?
You're trying to solve this problem using a view hierarchy like this:
Problem is, in this position,
InverterView
has no control over howListView
is drawn. But you know who does have control over howListView
is drawn?ListView
's parent layout does. In other words, what you really want is a hierarchy like this:Now
InverterLayout
is responsible for drawingListView
, and can apply effects to it.When using this, ensure your child view has its own background. If the view is transparent and the window background shows through, that window background will not be inverted, because the
InverterLayout
has no control over how the window is drawn.