activity_main.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rl"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
tools:context=".MainActivity"
android:background="#eae4e2"
>
<!--
android:textColorHint
Color of the hint text.
May be a reference to another resource, in the form
"@[+][package:]type:name" or to a theme attribute
in the form "?[package:][type:]name".
May be a color value, in the form of
"#rgb", "#argb", "#rrggbb", or "#aarrggbb".
-->
<EditText
android:id="@+id/et"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:padding="10dp"
android:hint="Default hint color"
/>
<EditText
android:id="@+id/et2"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:hint="Hint color red"
android:padding="10dp"
android:layout_below="@+id/et"
android:textColorHint="#ff0000"
/>
<EditText
android:id="@+id/et3"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_below="@+id/et2"
/>
</RelativeLayout>
MainActivity.java
package com.cfsuman.me.androidcodesnippets;
import android.graphics.Color;
import android.os.Bundle;
import android.app.Activity;
import android.widget.EditText;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Get the widgets reference from XML layout
EditText et = (EditText) findViewById(R.id.et);
EditText et2 = (EditText) findViewById(R.id.et2);
EditText et3 = (EditText) findViewById(R.id.et3);
/*
setHintTextColor (int color)
Sets the color of the hint text for all the states
(disabled, focused, selected...) of this EditText.
*/
et3.setHintTextColor(Color.BLUE);
// Set the initial instructional text of third EditText
// Set hint of the third EditText
et3.setHint("Hint color blue programmatically");
}
}


- How to create multiline EditText in Android
- How to use EditText TextChangedListener in Android
- How to create a transparent EditText in Android
- How to add placeholder to an EditText in Android
- How to disable EditText in Android
- How to clear EditText in Android
- How to change EditText cursor color in Android
- How to change EditText background color in Android
- How to change EditText bottom border color in Android
- How to create rounded corners EditText in Android
- How to create a custom Toast layout in Android
- How to change position of a Toast message in Android
- How to create MultiChoice AlertDialog in Android
- How to get Spinner selected item text in Android
- How to set prompt text in a Spinner in Android