Android Invalidate doesn't refresh the whole activity

Bagusflyer picture Bagusflyer · Nov 24, 2013 · Viewed 9.8k times · Source

Here are the components in my activity:

  1. A list view
  2. Bottom bar which is actually a RelativeLayout under the list view. It's dynamically shown or hidden in my program. Something like this

Code

if ( condition ) {           
   bottombar.getLayoutParams().height = RelativeLayout.LayoutParams.WRAP_CONTENT;               
} else {        
   bottombar.getLayoutParams().height = 0;
}        
this.findViewById(android.R.id.content).invalidate();

It seems the invalidate() doesn't work at all. If I add something, I set the height of the bottom bar. The view is not refreshed at all. It will be only refreshed after I scroll my ListView.

Any idea? Thanks

Answer

Infinite Recursion picture Infinite Recursion · Nov 24, 2013

Instead of invalidate(), you should call requestLayout() after changing the height of the relative layout.