gpt4 book ai didi

android - TextInputLayout在聚焦和未聚焦状态下如何保持文本颜色相同?

转载 作者:行者123 更新时间:2023-11-29 01:09:45 25 4
gpt4 key购买 nike

我想让文本输入布局中的文本颜色在处于聚焦或未聚焦状态时保持相同。当我点击编辑文本(聚焦状态)时,我看到不同的颜色,当它没有聚焦时,我看到不同的颜色。代码附在下面。

text_with_edit_text.xml

<LinearLayout
android:id="@+id/linearLayoutlocality_2"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:id="@+id/tv_locality_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hintTextAppearance="@style/custom_text_appearance">
<EditText
android:id="@+id/et_locality_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="locality_2"
/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>

样式.xml

<style name="custom_text_appearance" parent="@android:style/TextAppearance">
<item name="android:textSize">12sp</item>
<item name="android:typeface">normal</item>
<item name="android:textColor">#FF5733</item>
</style>

**

  • 例如

** - 我附上下面的图片, I want the color of 'Nombre'(text focused at this movement) to remain same when it is not focused. Also note that the color of hint in EditText should not be same as that of 'Nombre'(when it is in unfocused state)

最佳答案

试试这个我的 friend

 <android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayoutUname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textColorHint="@color/colorPrimary"
android:theme="@style/MYAppTheme">

<EditText
android:id="@+id/edtUname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Please Enter User Name"
android:imeOptions="actionNext"
android:textColorHint="@color/colorPrimary"
android:theme="@style/MYAppTheme" />
</android.support.design.widget.TextInputLayout>

<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayoutEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textColorHint="@color/colorPrimary"
android:theme="@style/MYAppTheme">

<EditText
android:id="@+id/edtEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Please Enter Email Address"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:textColorHint="@color/colorPrimary"
android:theme="@style/MYAppTheme" />
</android.support.design.widget.TextInputLayout>

主题是

<style name="MYAppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorControlNormal">@color/colorPrimary</item>
<item name="colorControlActivated">@color/colorPrimary</item>
<item name="colorControlHighlight">@color/colorPrimaryDark</item>
</style>

现在根据您的要求更改颜色

关于android - TextInputLayout在聚焦和未聚焦状态下如何保持文本颜色相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44041356/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com