2016-12-13 122 views
1

我无法弄清楚如何将editText的默认颜色从粉红色更改为蓝色。我manged使用改变下划线:如何更改默认editText的着色方面Andriod Studio

android:backgroundTint="@color/blue" 

这是我目前的XML我EDITTEXT箱

<EditText 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:inputType="textPersonName" 
android:text="@string/customword" 
android:ems="10" 
android:id="@+id/customword" 
android:layout_gravity="start" 
android:tint="@color/blue" 
android:textAlignment="viewStart" 
android:textSize="14sp" 
android:textColorLink="@color/blue" //no affect 
android:textColorHint="@color/blue" //no affect 
android:textColorHighlight="@color/blue" //no affect 
android:backgroundTint="@color/blue" 
tools:ignore="UnusedAttribute" /> 

下面是一些屏幕截图我想从粉红改变方面: 在这里输入图像描述

Pink Bubble

Pink Line

谢谢先进的 - 杰克

+1

[Set EditText cursor color]可能重复(http://stackoverflow.com/questions/7238450/set-edittext-cursor-color) – nikis

回答

1

光标(和气泡),颜色应符合您colorAccent,所以设置你的强调色的颜色,你想用:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/blue</item> 
</style> 

或者,如果您希望只改变口音颜色为EditText,你可以使用一个主题覆盖:

<style name="AppTheme.EditTextOverlay" parent = "ThemeOverlay.AppCompat.Light"> 
    <item name="colorAccent">@color/blue</item> 
</style> 

然后将其应用到你的EditText

<EditText android:id="@+id/customword" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="start" 
    android:inputType="textPersonName" 
    android:text="@string/customword" 
    android:ems="10" 
    android:textAlignment="viewStart" 
    android:textSize="14sp" 
    android:theme="@style/AppTheme.EditTextOverlay" /> 
+0

非常感谢谢谢! ☺️ –

0

我发现这个答案here,这是否解决您的问题?

将android:textCursorDrawable属性设置为@null应导致使用android:textColor作为光标颜色。

相关问题