使View可单击,而不是View中的Edittext

时间:2017-05-10 01:48:18

标签: android android-edittext android-textinputedittext

我的EditText包含在TextInputLayout inside LinearLayout中,我希望在{{1}时显示fragmentLinearLayout。但是touched正在截取EditText

我尝试在touchfocusable="false"上设置clickable="false"EditText,但现在TextInputLayout除了更改提示{{}之外没有做任何事情1}}一点点。

由于灰色touch更改,我不想设置color slightly

我的xml:

enabled="false"

我现在的解决方案:只需在edittext

之上放置一个视图

3 个答案:

答案 0 :(得分:1)

试试这个,可能是它的工作

在线性布局中设置

 android:clickable="true"

在editText中设置

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

从TextInputlayout中移除此2行

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

答案 1 :(得分:0)

试试android:enabled="false"。我不确定,但它可能有效。

答案 2 :(得分:0)

尝试在LinearLayout上使用android:descendantFocusability="blocksDescendants",让儿童观看无法集中注意力。

您也可以尝试使用两种可聚焦属性

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

修改

对LinearLayout的每个子视图尝试android:duplicateParentState="true"。您还可以查看this question。有人提到EditText上的inputType可以拦截点击。