我需要自定义Edittext,如下所示。我的应用程序hinttext颜色不会在三星galaxy neo中改变,所有提示都隐藏在这个编辑文本中。我尝试在xml中更改textHintColor并尝试:
DesiredSize
但只是在这部手机中没有变化。
nameEditText.setHintTextColor(getResources().getColor(R.color.primary));
我也改变了应用主题,但没有改变。 这是edittext的用法:
public class EditText extends android.widget.EditText {
public EditText(Context context) {
super(context);
final Typeface tf = Typeface.createFromAsset(context.getAssets(), Constants.APPLICATION_FONT);
setTypeface(tf);
// setTextSize(this.getTextSize());
}
public EditText(Context context, AttributeSet attrs) {
super(context, attrs, android.R.attr.editTextStyle);
final Typeface tf = Typeface.createFromAsset(context.getAssets(), Constants.APPLICATION_FONT);
setTypeface(tf);
// setTextSize(this.getTextSize());
}
public EditText(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
final Typeface tf = Typeface.createFromAsset(context.getAssets(), Constants.APPLICATION_FONT);
setTypeface(tf);
// setTextSize(this.getTextSize());
}
答案 0 :(得分:4)
只需将其添加到EditText的布局:
android:textColorHint="#FFFFFF" // any color
或您可以从颜色res文件中设置颜色
android:textColorHint="@color/red"
答案 1 :(得分:0)
答案 2 :(得分:0)
<item name="colorAccent">@android:color/black</item>
change your colorAccent to your desired color inside your Theme,this will change your EditText line,Cursor as well as your hint
or you can also include this style inside your style.xml
<style name="TextLabel" parent="TextAppearance.AppCompat">
<!-- Hint color and label color in FALSE state -->
<item name="android:textColorHint">@android:color/black</item>
<item name="android:textSize">20sp</item>
<!-- Label color in TRUE state and bar color FALSE and TRUE State -->
<item name="colorAccent">@android:color/black</item>
<item name="colorControlNormal">@android:color/black</item>
<item name="colorControlActivated">@android:color/black</item>
</style>
then inside your TextInputLayout you can put it like this
<android.support.design.widget.TextInputLayout
android:id="@+id/input_layout_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/TextLabel">
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/password"
android:drawableStart="@drawable/password"
android:maxLines="1"
android:hint="password"
android:inputType="textWebPassword" />
</android.support.design.widget.TextInputLayout>