ulmaxy
ulmaxy

Reputation: 870

Restrict parent from getting focus clicking on one of its children

I have a RelativeLayout, that has two others layouts inside of it. What I want to do is to let to the parent layout to get focus when I click on the area of the first children layout (so onClick() method will be called for the parent), and do nothing when I click on the area of the second children.

descendantsFocusability doesn't work in my case, since it defines focusability for all the children and it's the same for all of them (which is clearly not my case).

Upvotes: 1

Views: 270

Answers (1)

qantik
qantik

Reputation: 1097

First set this attribute to the layouts in the xml-files:

 android:focusableInTouchMode="true"

Then you can, by applying requestFocus(), shift the focuses around your layouts.

Upvotes: 1

Related Questions