I have special layout using TextInputEditText
and TextInputLayout
. Its form like layout but one View
is only TextInputEditText
by its look. It will not have any editable parts. Its purpose is to be informative and acts like Button
. And there is a problem. I wrapped this EditText
in FrameLayout
and FrameLayout
acts like Button
which have onClickListener
. Problem is that it is not reacting to clicks. How to enable it? ( FrameLayout
should be in front of its children in terms of clickable area)
<FrameLayout
android:id="@+id/updateButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/etLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/form_edit_text_style"
app:errorEnabled="true"
android:clickable="false"
android:focusable="false"
android:hint="@string/et_hint_num">
<com.google.android.material.textfield.TextInputEditText
android:id="@+id/etField"
android:layout_width="match_parent"
android:inputType="text"
android:enabled="false"
android:clickable="false"
android:focusable="false"
style="@style/form_inner_style"/>
</com.google.android.material.textfield.TextInputLayout>
</FrameLayout>
Can you try below custom FrameLayout:-
public class MyFrameLayout extends FrameLayout {
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
// true if you do not want the children to be clickable.
return mShouldInterceptAllTouch;
}
}
Also, try:-
focusableInTouchMode=false
for editText as editText is taking the focus.