给予你给予的相同风格Text Input Style
Edittext
<!--Text Input Style-->
<style name="styleTextInputLayout" parent="Widget.Design.TextInputLayout">
<item name="android:textColor">?android:attr/textColorSecondary</item>
<item name="android:textColorHint">?android:attr/textColorSecondaryInverse</item>
</style>
<!--EditText-->
<style name="styleEditText" parent="Widget.AppCompat.EditText">
<item name="android:textColor">?android:attr/textColorSecondary</item>
<item name="android:textColorHint">?android:attr/textColorSecondaryInverse</item>
</style>
给上面的标签你各自的颜色
<android.support.design.widget.TextInputLayout
style="@style/styleTextInputLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/edtTextFirstName"
style="@style/styleEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dimen_5_dp"
android:layout_marginTop="@dimen/dimen_5_dp"
android:hint="@string/hint_first_name"
android:imeOptions="actionNext"
android:inputType="textPersonName|textCapWords"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
上面的代码适用于
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
我遇到了22
版本问题,可能存在一些错误,因为文本输入忽略了提供给它的样式。
com.android.support:design
下面的解决方案23
是:
样式.xml
<style name="styleTextInputTextAppearance" parent="TextAppearance.AppCompat">
<item name="android:textColorHint">?android:attr/textColorSecondaryInverse</item>
</style>
将主题设置为 TextInputLayout
<android.support.design.widget.TextInputLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:theme="@style/styleTextInputTextAppearance">
<EditText
android:id="@+id/edtTextTowerName"
style="@style/styleEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/dimen_5_dp"
android:layout_marginTop="@dimen/dimen_5_dp"
android:hint="@string/hint_tower_name"
android:imeOptions="actionNext"
android:inputType="textCapWords"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>