Android 具有inputType的TextView在按下时仍会获得touchlistener,尽管其已禁用

Android 具有inputType的TextView在按下时仍会获得touchlistener,尽管其已禁用,android,android-layout,Android,Android Layout,我试图用textView显示密码,我使用了inputType“textPassword”,它显示的是我想要的点密码文本。这个文本视图在相对布局中,我试图从相对布局中获取clicklistener,但当我在文本视图上方按时,它没有单击,当我删除输入类型时,它工作正常。这是我到目前为止所做的尝试。 ` ` 您是否尝试过从java代码而不是xml设置输入类型?这有区别吗 您使用了 android:clickable=“false” android:enabled=“false” android:fo

我试图用textView显示密码,我使用了inputType“textPassword”,它显示的是我想要的点密码文本。这个文本视图在相对布局中,我试图从相对布局中获取clicklistener,但当我在文本视图上方按时,它没有单击,当我删除输入类型时,它工作正常。这是我到目前为止所做的尝试。 `


`

您是否尝试过从java代码而不是xml设置输入类型?这有区别吗

您使用了

android:clickable=“false” android:enabled=“false” android:focusable=“false”

对于您的
TextView
,只有当您在此
TextView
之外单击时,它才会收到任何单击事件。您的布局将收到输入单击


另外,
inputType“textPassword”
视图的点击事件没有影响。

您可以按专业语法而不是xml文件设置输入类型

 <TextView
    android:id="@+id/textView_settings_password"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_toRightOf="@+id/settings_password_title"
    android:clickable="false"
    android:enabled="false"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:gravity="right"
    android:text="123abc[enter image description here][1]"
    android:textColor="@color/colorPrimary" /> 

当我按下文本视图上方的按钮时,你的意思是什么?嘿,我的意思是,如果按下区域位于虚线区域上方,即你正在使用的文本视图
android:layout\u width=“match\u parent”
用于您的
文本视图
因此它将覆盖几乎整个
相对性视图
,然后它被禁用且不可聚焦,因此这里有一些严重的代码问题,伙计!!是的,我不想从文本视图中获取click事件,实际上我想从relativeLayout中获取它。这就是为什么我试图解散它,希望不会得到点击事件,但它仍然不工作。我编辑了答案,它工作(测试)。试试这个;)WC,我的荣幸:)@jawadturk您的问题不是很清楚,但据我所知,在提供inputType时,您遇到了编辑文本的问题。尝试将编辑文本替换为密码的自定义编辑文本库,如下所示:其textView不是editText,我尝试在textView中显示密码,但其托管在相对布局中,我正在对相对布局使用click listener以打开另一个活动。当我按下包含文本视图的部分时,clicklistener不工作。我找到了正确的答案。
 <TextView
    android:id="@+id/textView_settings_password"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_toRightOf="@+id/settings_password_title"
    android:clickable="false"
    android:enabled="false"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:gravity="right"
    android:text="123abc[enter image description here][1]"
    android:textColor="@color/colorPrimary" /> 
 TextViewPassword.setInputType( InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD );
 tv.setTransformationMethod(PasswordTransformationMethod.getInstance());