当处于聚焦或未聚焦状态时,我想保持TEXT INPUT LAYOUT中文本的颜色相同。当我点击EDIT TEXT(聚焦状态)时,我看到不同的颜色,当它没有聚焦时,我看到不同的颜色。 代码如下。
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>
styles.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>
**
答案 0 :(得分:1)
试试我的朋友
<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>
现在根据您的要求更改颜色
答案 1 :(得分:0)
希望这对你有用: -
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
<!--EditText hint color-->
<item name="android:textColorHint">@color/default_app_white</item>
<!-- TextInputLayout text color-->
<item name="colorControlActivated">@color/default_app_green</item>
<!-- EditText line color when EditText on-focus-->
<item name="colorControlHighlight">@color/default_app_green</item>
<!-- EditText line color when EditText in un-focus-->
<item name="colorControlNormal">@color/default_app_white</item>
</style>