【发布时间】:2020-07-02 06:21:36
【问题描述】:
我已经创建了带有提示的 TextInputLayout(OutlinedBox)。预计以 3 色显示。
- 当占位符聚焦时,“浮动标签”应以颜色 1(黄色)显示
- 当占位符未聚焦时,“提示”应以颜色 2(灰色)显示
- 当占位符未聚焦时,“浮动标签”应显示为彩色(蓝色)
但是,未聚焦的“提示”和未聚焦的“浮动标签”始终采用与在占位符中指定的颜色相同的颜色(在这种情况下,颜色为 2-灰色)。
这里我使用了依赖com.google.android.material:material:1.2.0-alpha05
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/tv_mb_text_layout3"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/tv_mb_text_layout2"
app:layout_constraintLeft_toLeftOf="parent"
style="@style/MBFormTextInputStyle"
android:hint="label_text"
app:errorEnabled="true">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:text="Priyanka"
android:layout_height="wrap_content"/>
</com.google.android.material.textfield.TextInputLayout>
<!-- Style for Hint -->
<style name="hint_appearance" parent="TextAppearance.AppCompat">
<item name="android:textSize">8sp</item>
<item name="android:textColor">@android:color/holo_orange_dark</item>
</style>
<style name="MBFormTextInputStyle" parent="Widget.MaterialComponents.TextInputLayout.OutlinedBox.Dense">
<item name="errorTextAppearance">@style/error_a`enter code here`ppearance</item>
<item name="errorTextColor">@android:color/holo_purple</item>
<item name="boxStrokeErrorColor">@android:color/holo_purple</item>
<item name="hintTextAppea`enter code here`rance">@style/hint_appearance</item>
<item name="hintTextColor">@android:color/holo_blue_dark</item>
<item name="android:textColorHint">@android:color/holo_purple</item>
</style>
【问题讨论】:
标签: android android-layout material-design android-styles android-textinputlayout