Android Layout make all children's not clickable

后端 未结 12 2202
一生所求
一生所求 2021-01-01 12:45

I am using Relative Layout and many buttons in it with TextViews etc.I want to make all of them not clickable unless some event happens.

12条回答
  •  无人及你
    2021-01-01 13:21

    I found an alternative way to achieve this. You may create a blocking LinearLayout on top all its sibling views in the RelativeLayout like below:

    
    
        
        ...
        
    
        
    
    
    

    Later you may toggle the LinearLayout's visibility to GONE to allow the children views to be clickable again:

    mMask.setVisibility(View.VISIBLE); // blocks children
    mMask.setVisibility(View.GONE); // children clickable
    

提交回复
热议问题