setVisibility(GONE) view becomes invisible but still occupies space

后端 未结 13 2014
我在风中等你
我在风中等你 2020-12-03 03:56

I\'ve got a view that is effectively is a button. Here is its XML layout (add_new.xml)




        
13条回答
  •  星月不相逢
    2020-12-03 04:48

    This is my solution. Create a new layout file with name "special.xml", copy the code to the file.

    
    
    
    
    

    Use condition to inflate the empty layout inside the newview. Don't Use the view.setVisibility(View.GONE);.

    if(true){
      view=mInflater.inflate ( R.layout.special,parent, false );
    }else{
      view=mInflater.inflate(R.layout.normal,parent,false);
      // The view that you want to be visible
    }
    

提交回复
热议问题