首页 > 解决方案 > 文本输入布局设计有问题?

问题描述

标签提示颜色不起作用,我创建了 Bluesky 颜色,但仅适用于线性框,但标签不起作用。

<android.support.design.widget.TextInputLayout
            android:id="@+id/til1"               
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:layout_marginStart="5dp"
            android:layout_marginTop="14dp"
            android:layout_marginEnd="0dp"
            android:layout_weight=".8"
            android:textColorHint="@color/BlueSky"
            app:boxStrokeColor="@color/BlueSky"
            app:counterEnabled="true"
            app:counterMaxLength="7"
            app:errorEnabled="true"
            app:hintEnabled="true">

            <android.support.design.widget.TextInputEditText
                android:id="@+id/tid1"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="9dp"
                android:elevation="7dp"
                android:hint="Test"
                android:inputType="number|numberDecimal"
                android:maxLength="7"
                android:textSize="18sp" />
 </android.support.design.widget.TextInputLayout>

mi构建gradle:

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support:design:28.0.0'
    implementation 'com.android.support.constraint:constraint- 
    layout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation'com.android.support.test.espresso:espresso-core:3.0.2'
}

我使用的是 android studio 3.4 版。

在此处输入图像描述

标签: android

解决方案


输入布局上的标签颜色是项目的 colorAccent。如果您将此颜色更改为 BlueSky,您将看到您想要的。

<color name="colorAccent">#D81B60</color>

但也许还有另一种方法可以在不更改 colorAccent 的情况下设置此小部件的样式(因为其他小部件也使用此颜色)。


推荐阅读