【问题标题】:How to change coloring aspects of default editText Android Studio如何更改默认editText Android Studio的着色方面
【发布时间】:2016-12-13 20:35:18
【问题描述】:

我不知道如何将 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" />

以下是一些我想从粉红色更改的方面的屏幕截图: 在此处输入图片说明

Pink Bubble

Pink Line

【问题讨论】:

标签: java android xml android-layout


【解决方案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" />

【讨论】:

    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-08-24
      • 1970-01-01
      • 2016-06-26
      • 2016-06-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多