How to change visibility of layout programmatically

后端 未结 5 1206
温柔的废话
温柔的废话 2020-12-03 06:13

There is the way to change visibility of View, but how can I change programmatically visibility of layout defined in XML? How to get layout object?



        
5条回答
  •  渐次进展
    2020-12-03 07:15

    Use this Layout in your xml file

    
    
    

    Define your layout in .class file

     LinearLayout linearLayout = (LinearLayout) findViewById(R.id.contacts_type);
    

    Now if you want to display this layout just write

     linearLayout.setVisibility(View.VISIBLE);
    

    and if you want to hide layout just write

     linearLayout.setVisibility(View.INVISIBLE);
    

提交回复
热议问题