android – 禁用EditText可编辑性和焦点(如TextView)

android – 禁用EditText可编辑性和焦点(如TextView),第1张

概述有没有办法使EditText行为像 Android中的TextView(XML是首选)? 我已经尝试过以下内容: android:editable="false" android:focusable="false" android:focusableInTouchMode="false" android:cursorVisible="false" android:longClickable 有没有办法使EditText行为像 Android中的TextVIEw(XML是首选)?
我已经尝试过以下内容:
androID:editable="false" androID:focusable="false" androID:focusableIntouchMode="false" androID:cursorVisible="false" androID:longClickable="false"

这是有效的,但是我仍然可以触摸EditText来获取焦点(橙色的边缘),尽管焦点丢失了,一旦我删除我的手指.
我不知道focusableIntouchMode是做什么的,但是当我继续接触时它不会移除焦点.

而我不使用白色背景TextVIEw的原因是TextVIEw的背景是丑陋的. EditText的背景有圆角和阴影效果.

提前致谢.

解决方法 EditText和TextVIEw非常相似.我将硬编码到 EditText.java中的唯一区别是将可编辑默认设置为true,您可以手动设置.除此之外,EditText style是:
<style name="Widget.EditText">    <item name="androID:focusable">true</item>    <item name="androID:focusableIntouchMode">true</item>    <item name="androID:clickable">true</item>    <item name="androID:background">@androID:drawable/edit_text</item>    <item name="androID:textAppearance">?androID:attr/textAppearanceMediumInverse</item>    <item name="androID:textcolor">@androID:color/primary_text_light</item>    <item name="androID:gravity">center_vertical</item></style>

和TextVIEw是:

<style name="Widget.TextVIEw">    <item name="androID:textAppearance">?androID:attr/textAppearanceSmall</item></style>

我的猜测是@androID:drawable / edit_text是橙色框的源.的确,it contains:

<item androID:state_pressed="true" androID:drawable="@drawable/textfIEld_pressed"/>

最简单的方法可能是将其背景设置为默认值:

机器人:背景= “@机器人:可拉伸/ textfIEld_default”

总结

以上是内存溢出为你收集整理的android – 禁用EditText可编辑性和焦点(如TextView)全部内容,希望文章能够帮你解决android – 禁用EditText可编辑性和焦点(如TextView)所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1131975.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-30
下一篇2022-05-30

发表评论

登录后才能评论

评论列表(0条)

    保存