Android Invalidate doesn't refresh the whole activity

10,137

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

Share:
10,137
Bagusflyer
Author by

Bagusflyer

Updated on June 28, 2022

Comments

  • Bagusflyer
    Bagusflyer almost 2 years

    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