1

I have an EditText that is wrapped in a TextInputLayout that is inside a LinearLayout and I want to show a fragment when the LinearLayout is touched. However the EditText is intercepting the touch.

I tried setting focusable="false" and clickable="false" on the EditText and the TextInputLayout but now the touch doesn't do anything except change the hint color slightly for a little bit.

I don't want to set enabled="false" because of the grayed out style color changes.

My xml:

<LinearLayout
            android:id="@+id/type_layout"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.design.widget.TextInputLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                android:id="@+id/type_input_layout"
                android:clickable="false"
                android:focusable="false">

                <EditText
                    android:id="@+id/type_input"
                    android:hint="Type"
                    android:text="Public"
                    android:clickable="false"
                    android:focusable="false"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:inputType="textNoSuggestions|textMultiLine"
                    android:background="@color/transparent"
                    android:gravity="left"
                    android:textSize="22sp"/>

            </android.support.design.widget.TextInputLayout>

        </LinearLayout>

My solution for now: just put a view on top of the edittext

nic
  • 131
  • 1
  • 8

4 Answers4

2

try this ,may be its working

set in your linear layout

 android:clickable="true"

set in your editText

 android:clickable="false"
 android:focusable="false"

remove from TextInputlayout this 2 lines

android:clickable="false"
android:focusable="false"
Jinal Awaiya
  • 441
  • 3
  • 14
0

Try android:enabled="false". I'm not sure but it might work.

0

Try using android:descendantFocusability="blocksDescendants" on your LinearLayout to make children view not focusable.

You can also try using both focusable properties

android:focusable="false"
android:focusableInTouchMode="false"

EDIT:

Try android:duplicateParentState="true" for every child view of the LinearLayout. You can also look at this question. There is someone mentioning that inputType on EditText can intercept the click.

Community
  • 1
  • 1
Nicolas
  • 6,611
  • 3
  • 29
  • 73
0

In xml for EditText you should declare:

        android:clickable="false"
        android:longClickable="false"

This will make it not able to take over the click.

basileus
  • 295
  • 3
  • 9