Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/208.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何更改默认editText Android Studio的着色方面_Java_Android_Xml_Android Layout - Fatal编程技术网

Java 如何更改默认editText Android Studio的着色方面

Java 如何更改默认editText Android Studio的着色方面,java,android,xml,android-layout,Java,Android,Xml,Android Layout,我不知道如何将editText的默认颜色从粉红色更改为蓝色。我设法用以下方法更改下划线: android:backgroundTint="@color/blue" 这是我当前的XML文本框 <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textPersonName" android:text="@string/customword"

我不知道如何将editText的默认颜色从粉红色更改为蓝色。我设法用以下方法更改下划线:

android:backgroundTint="@color/blue"
这是我当前的XML文本框

<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" />

以下是我想从粉色更改的方面的一些屏幕截图: 在此处输入图像描述

我找到了这个答案,这能解决你的问题吗

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

光标(和气泡)颜色应与您的颜色相匹配,因此请将重点颜色设置为您希望使用的颜色:

<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

<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" />

<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" />