Normally it's enough to set focusable, focusableInTouch + clickable to false. But here it does not work.
I want the parent LinearLayout to consume clicks on the EditText as well but it does not work...
<LinearLayout
android:id="@+id/llText"
android:layout_width="0dp"
android:layout_weight="1"
android:background="?attr/selectableItemBackground"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="@+id/tvText"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:paddingRight="5dp"
android:text="@null" />
<EditText
android:id="@+id/etText"
android:inputType="none"
android:gravity="center_horizontal"
android:focusable="false"
android:focusableInTouchMode="false"
android:clickable="false"
android:layout_width="wrap_content"
android:ems="4"
android:layout_gravity="center_vertical"
android:layout_height="wrap_content" />
</LinearLayout>
I tried editable=false and inputType=none but it does not work. Why not? The EditText consumes the click and does not hand it on to it's parent.
EDIT
I'm setting an onClickListener to the LinearLayout and it does not work if I directly press the EditText...
Late, but maybe somebody else needs this info. After setting focusable, focusableInTouch + clickable to false, add this in your java code:
editText.setMovementMethod(null);
editText.setKeyListener(null);
Don't forget to save those values to restore them later:
mMovementMethod = mEditText.getMovementMethod();
mKeyListener = mEditText.getKeyListener();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With