title: Having a custom View determine its own visibility
body: <p>I want to create a custom <code>View</code> that has display logic to determine its own visibility.  In the interest of keeping that logic contained and easily reusable, I created a <code>View</code> subclass, overrode <code>getVisibility()</code> and was planning on invalidating the <code>View</code> when events happen that might cause its visibility to have changed...  only to find out that a <code>View</code>'s visibility can only be changed by calling <code>setVisibility()</code> and not by overriding <code>getVisibility()</code>.  See Romain Guy's answer to <a href="https://stackoverflow.com/questions/6796299/view-getvisibility-isshown-return-incorrect-visibility">this question</a>.</p>
  
  <p>Is there is a particular method that gets called as part of the normal <code>View</code> lifecycle/rendering process that would be ideal to override, in which I would call <code>setVisibilty()</code>?  Since I already call <code>invalidate()</code>, overriding it to call <code>setVisibility()</code> works.  But is that the ideal place for it?  It seems like setting a <code>View</code>'s attributes in <code>invalidate()</code> would go against best practices.</p>
  
  <p><strong>Clarification:</strong>  Andr has pointed out that there are many things that might cause the custom <code>View</code>'s visibility to change and those scenarios are very specific the custom view's usage.  That's very true.  But this question isn't about how to <em>trigger</em> the appearance to refresh - <code>invalidate()</code> seems to be the standard way of telling Android that a View's appearance has changed, is it not?  Instead, this is a best practices question about <em>where</em> to call <code>setVisibility()</code> once the custom <code>View</code> has been invalidated.  I wouldn't want to made changes in the wrong part of the process, like in <code>onMeasure()</code> for example.  If anyone has links, I would love to see a diagram of Android's UI rendering process.</p>