Reputation: 51
I am working on android application i am using two relative layouts,I need to disable user interaction on one relative layout,i tried with layout setEnabled false,but it didn't work out,can anyone help me in solving this.
Upvotes: 2
Views: 5989
Reputation: 6631
You can do this in java with the method relativeLayout.setClickable(false)
or in xml android:clickable="false"
Upvotes: 5
Reputation: 21
I think you can easily setClickable(false) to the relative layout that you don't want to interact. Hope this help.
Upvotes: 1
Reputation: 16537
It depends on what would you like to disable and what kinds of interaction are handled by that RelativeLayout and its contents.
The easiest way to turn off touches and key presses is to override dispatch* methods and provide empty implementations. It prevents all touches, keys, etc. from being passed to the children. For example to disable touches and keys:
public class MyRelativeLayout extends RelativeLayout{
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
return true;
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
return true;
}
}
Upvotes: 1