<android.support.constraint.ConstraintLayout
android:id="@+id/fragment_phone_registration_profile_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
>
<android.support.design.widget.TextInputLayout
android:id="@+id/fragment_fio_input_surname_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:hint="@string/fragment__phone_registration_FIO"
android.support.design:hintAnimationEnabled="true"
android.support.design:hintEnabled="true"
android.support.design:layout_marginTop="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/image_fio"
app:layout_constraintTop_toTopOf="parent"
android:focusable="false"
android:focusableInTouchMode="false"
android:clickable="false"
>
<android.support.design.widget.TextInputEditText
android:id="@+id/fragment_phone_registration_profile_text"
style="@style/R16"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLength="200"
android:maxLines="4"
android:focusable="false"
android:clickable="false"
android:focusableInTouchMode="false"
/>
</android.support.design.widget.TextInputLayout>
</android.support.constraint.ConstraintLayout>
public class InterceptableConstraintLayout extends ConstraintLayout {
private Set<View> mIntercepatbleViews = new HashSet<>();
public InterceptableConstraintLayout(Context context) {
super(context);
}
public InterceptableConstraintLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public InterceptableConstraintLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
public void addViewToIntercept(View v) {
if (v == null) return;
mIntercepatbleViews.add(v);
}
public void removeViewFromInterception(View v) {
if (v == null) return;
mIntercepatbleViews.remove(v);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_DOWN
&& mIntercepatbleViews.size() > 0
&& getChildCount() > 0) {
int x = (int) ev.getX();
int y = (int) ev.getY();
Rect hitRect = new Rect();
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
child.getHitRect(hitRect);
if (hitRect.contains(x, y) && mIntercepatbleViews.contains(child)) return true;
}
return super.onInterceptTouchEvent(ev);
} else return super.onInterceptTouchEvent(ev);
}
}
InterceptableConstraintLayout mLo = findViewById(R.id.fragment_phone_registration_profile_box);
View mEt = findViewById(R.id.fragment_fio_input_surname_info);
mLo.addViewToIntercept(mEt);
mLo.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.e("mLo", "clicked");
}
});