【问题标题】:How to disable highlight when writing on EditText?在 EditText 上书写时如何禁用突出显示?
【发布时间】:2014-03-11 17:36:09
【问题描述】:

在我的EditText 上书写时,我正在尝试更改颜色或禁用文本的突出显示。

  • 我该怎么做?
  • 如何为突出显示设置圆角边框?

我想这样做,因为当我开始在我的 EditText 上书写时,突出显示与我的 EditText 的圆角重叠,看起来很糟糕。

我的 EditText 的背景颜色和圆角代码:

<?xml version="1.0" encoding="utf-8"?> 

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">    
<corners android:radius="5dp" />
<solid android:color="#FFFFFF"/> 

</shape>

我的编辑文本代码:

<EditText
        android:id="@+id/editTextUsuario"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/propertieseditextlogin"
        android:ems="10" >
<requestFocus />
</EditText>

我的问题有两个例子:

【问题讨论】:

  • 您好,要删除重叠圆角,请使用填充。 android:padding="1dp" //或者你可以根据需要增加

标签: android text colors android-edittext highlight


【解决方案1】:

要禁用编辑文本的突出显示,您可以编写以下内容。

android:background="#00000000"

【讨论】:

    【解决方案2】:

    解决你的second problem

    为您的 EditText 提供 填充

    例子:-

    <EditText
            android:id="@+id/editTextUsuario"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/propertieseditextlogin"
            android:paddingLeft="6dp"
            android:ems="10" >
    <requestFocus />
    </EditText>
    

    【讨论】:

    • @ParkEunNeul :它是可绘制的。
    【解决方案3】:

    使用 android:padding 给 editext 一个填充或将背景属性设置为白色

    【讨论】:

      【解决方案4】:

      尝试将此属性添加到您的 editText 以禁用突出显示。

      android:defaultFocusHighlightEnabled="false"
      

      您可以通过创建自定义视图扩展编辑文本以编程方式创建带有圆角的高亮,但这确实需要大量工作。 也可以看看材料设计,使用这个库,你可以很容易地实现带有圆角的编辑文本。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2013-07-05
        • 2011-05-01
        • 2021-11-27
        • 2011-10-12
        • 1970-01-01
        • 1970-01-01
        • 2012-06-02
        相关资源
        最近更新 更多