下划线光标下

问题描述:

我已经实现自定义的EditText,具有自定义样式:下划线光标下

<android.support.design.widget.TextInputLayout 

      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:hint="Username" 
      android:textColorHint="@color/white" 
      app:hintAnimationEnabled="true" 
      app:hintTextAppearance="@style/TExtAppearance" 
      > 

      <com.app.farmtrace.fieldagent.CustomView.EditText_SemiBold 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:textColor="@color/colorAccent" 
       android:theme="@style/EditTextStyle" 
       android:id="@+id/username" 
       android:maxLines="1" 
       android:maxLength="50" 
       android:inputType="textEmailAddress|textNoSuggestions" 
       android:nextFocusDown="@+id/password" 
       /> 

     </android.support.design.widget.TextInputLayout> 

这是屏幕:

enter image description here

有刚光标,现在当我再次选择光标我得到这个:

enter image description here

我不想要光标下面的黄色下划线。

这是用Android 7.0在Moto g4中测试的。

<style name="TExtAppearance"> 
    <item name="android:textColor">@color/white</item> 
    <item name="android:textColorHighlight">@color/white</item> 
    <item name="android:textColorHint">@color/white</item> 
    <item name="android:textColorLink">@color/white</item> 
    <item name="android:textSize">16sp</item> 
    </style> 



<style name="EditTextStyle" parent="Widget.AppCompat.EditText"> 
     <item name="colorControlNormal">@color/white</item> 
     <item name="colorControlActivated">@color/colorAccent</item> 
     <!--<item name="colorControlHighlight">@color/colorAccent</item>--> 
    </style> 

编辑 也越来越强调的错误,如果我SETERROR和文字不可见的错误:

enter image description here

尝试设置的inputType = “textNoSuggestions” 在android系统

您编辑文本
 android:inputType="textNoSuggestions" 
+0

alresy安卓

<style name="MyEditTextStyle"> ... </style> 

TextInputEditText小号引用样式的一个实例:inputType =“textEmailAddress | textNoSuggestions”added,check the code we have attached –

+0

上传你的com.app.farmtrace.fieldagent.CustomView.EditText_SemiBold类 –

尝试在可绘制的帮助下设置背景

创建一个新的可绘制文件,例如。 et_back.xml,使背景/形状

然后用它作为你的编辑文本的背景...

如。让它成为你drawable.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle"> 
<stroke 
    android:width="2dp" 
    android:color="#000000" /> 
</shape> 

和你的EditText是:

<EditText 
    //other attribute/properties 
    android:background="@drawable/drawable_name"   
    /> 

我碰到了同样的问题。通过从我的TextInputEditText的自定义样式中删除Widget.AppCompat.EditText父级样式,我能够摆脱光标下划线。换句话说,我改变了我的TextInputEditText s'的风格,从这样的:

<style name="MyEditTextStyle" parent="Widget.AppCompat.EditText"> 
     ... 
</style> 

这样:

<android.support.design.widget.TextInputEditText 
    android:id="@+id/edit_username" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:theme="@style/MyEditTextStyle"/>