<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_enter_first_name"
android:layout_width="@dimen/btn_width"
android:layout_height="@dimen/editText_height"
android:layout_marginTop="@dimen/layout_margin_top_20"
android:background="@drawable/transperent_bg"
android:textColorHint="@color/white"
>
<EditText
android:id="@+id/enter_first_name"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="@dimen/layout_margin_left_5"
android:layout_marginTop="@dimen/layout_margin_top_1"
android:background="@color/transperent"
android:backgroundTint="@color/white"
android:inputType="textEmailAddress"
android:maxLines="1"
android:hint="@string/enter_first_name"
android:textColorHint="@color/white"
android:textColor="@color/white"
android:textSize="@dimen/textsize_12" />
</android.support.design.widget.TextInputLayout>
TextInputLayout input_layout_enter_first_name = (TextInputLayout) findViewById(R.id.input_layout_enter_first_name);
input_layout_enter_first_name.setHint(Html.fromHtml(“Required !!!”));
实际上它只是动态更改文本但无法将颜色更改为RED。
答案 0 :(得分:0)
您可以从TextInputLayout
设置style
文字提示颜色,如下所示:
TextInputLayout til = (TextInputLayout) view.findViewById(R.id.input_layout_enter_first_name);
til.setHintTextAppearance(R.style.One);
风格:
<style name="One">
<item name="android:textColor">@color/Red</item>
</style>
<style name="Two">
<item name="android:textColor">@color/color_primary</item>
</style>
设置所需的颜色,并在任何您喜欢的地方之间切换